FELIX-609 Fixed the issue as suggested in the description. If the user node is invalid, a new node will be returned.
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@670721 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/prefs/src/main/java/org/apache/felix/prefs/PreferencesImpl.java b/prefs/src/main/java/org/apache/felix/prefs/PreferencesImpl.java
index ac19aa6..b6aea58 100644
--- a/prefs/src/main/java/org/apache/felix/prefs/PreferencesImpl.java
+++ b/prefs/src/main/java/org/apache/felix/prefs/PreferencesImpl.java
@@ -161,6 +161,10 @@
}
}
+ public synchronized boolean isValid() {
+ return this.valid;
+ }
+
/**
* @see org.osgi.service.prefs.Preferences#put(java.lang.String, java.lang.String)
*/
@@ -645,4 +649,4 @@
child.applyChanges(current);
}
}
-}
\ No newline at end of file
+}
diff --git a/prefs/src/main/java/org/apache/felix/prefs/impl/PreferencesServiceImpl.java b/prefs/src/main/java/org/apache/felix/prefs/impl/PreferencesServiceImpl.java
index bed0080..18bde38 100644
--- a/prefs/src/main/java/org/apache/felix/prefs/impl/PreferencesServiceImpl.java
+++ b/prefs/src/main/java/org/apache/felix/prefs/impl/PreferencesServiceImpl.java
@@ -90,7 +90,7 @@
public synchronized Preferences getUserPreferences(String name) {
PreferencesImpl result = (PreferencesImpl) this.trees.get(name);
// if the tree does not exist yet, create it
- if (result == null) {
+ if (result == null || !result.isValid()) {
result = new PreferencesImpl(new PreferencesDescription(this.bundleId, name), this.storeManager);
this.trees.put(name, result);
}
@@ -120,4 +120,4 @@
list.addAll(this.trees.values());
return list;
}
-}
\ No newline at end of file
+}