Return-Path: Delivered-To: apmail-felix-dev-archive@www.apache.org Received: (qmail 11246 invoked from network); 3 Feb 2009 09:30:24 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 3 Feb 2009 09:30:24 -0000 Received: (qmail 17249 invoked by uid 500); 3 Feb 2009 09:30:23 -0000 Delivered-To: apmail-felix-dev-archive@felix.apache.org Received: (qmail 17214 invoked by uid 500); 3 Feb 2009 09:30:23 -0000 Mailing-List: contact dev-help@felix.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@felix.apache.org Delivered-To: mailing list dev@felix.apache.org Received: (qmail 17203 invoked by uid 99); 3 Feb 2009 09:30:23 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 03 Feb 2009 01:30:23 -0800 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.140] (HELO brutus.apache.org) (140.211.11.140) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 03 Feb 2009 09:30:21 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 95018234C48D for ; Tue, 3 Feb 2009 01:29:59 -0800 (PST) Message-ID: <2009581845.1233653399595.JavaMail.jira@brutus> Date: Tue, 3 Feb 2009 01:29:59 -0800 (PST) From: "Angelo van der Sijpt (JIRA)" To: dev@felix.apache.org Subject: [jira] Closed: (FELIX-609) PreferencesService might return invalid Preferences object for a user In-Reply-To: <1458344683.1213643984959.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/FELIX-609?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Angelo van der Sijpt closed FELIX-609. -------------------------------------- It has been a while, but yes, the trunk behavior is now OK. > PreferencesService might return invalid Preferences object for a user > --------------------------------------------------------------------- > > Key: FELIX-609 > URL: https://issues.apache.org/jira/browse/FELIX-609 > Project: Felix > Issue Type: Bug > Components: Preferences Service > Reporter: Angelo van der Sijpt > Assignee: Marcel Offermans > > When a Preferences object has been obtained for a given user, it can be removed using removeNode(). A following call to getUserPreferences(...) will then return the old, now invalid, Preferences object, leading to an IllegalStateException when trying to add new data to the node. From this moment on, it is not possible to obtain a valid Preferences object for this user. > The spec does not provide a definite answer about this case; 106.4 comes closest with "getUserPreferences(String) - Return a Preferences object associated with the user name that is given as argument. If the user does not exist, a new root is created atomically." Intuitively, one might expect that removeNode() restores the PreferencesService to the same state it was before getUserPreferences(...) was called. > The invalid Preferences object is caused by caching behavior in PreferencesServicesImpl's getUserPreferences(...), which checks whether a user's root node has already been created; if so, it will be returned, if not, it will be created. > 91 PreferencesImpl result = (PreferencesImpl) this.trees.get(name); > 92 // if the tree does not exist yet, create it > 93 if (result == null) { > 94 result = new PreferencesImpl(new PreferencesDescription(this.bundleId, name), this.storeManager); > 95 this.trees.put(name, result); > 96 } > The most plausible solution is to add an extra clause to the if-statement on line 93, stating something like > 93 if (result == null || !result.isValid()) { > provided that isValid() will then return the valid field of PreferencesImpl. > An alternative would be to detect the removal of a node which does not have a parent (is a root node), and then remove it from the PreferencesServiceImpl's trees; this is not that complicated, but requires some extra code. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.