7184287: (prefs) BackingStoreException when calling flush on root node[macosx]
authorkhazra
Tue, 24 Jul 2012 13:38:50 -0700
changeset 13367 0cc1e08af793
parent 13366 2f5fdf6d8c22
child 13368 da6b49e66a20
7184287: (prefs) BackingStoreException when calling flush on root node[macosx] Summary: Change implementation to enable user without administrative privileges to call flush Reviewed-by: alanb
jdk/src/macosx/classes/java/util/prefs/MacOSXPreferences.java
jdk/src/macosx/classes/java/util/prefs/MacOSXPreferencesFile.java
jdk/test/ProblemList.txt
--- a/jdk/src/macosx/classes/java/util/prefs/MacOSXPreferences.java	Tue Jul 24 12:17:39 2012 -0700
+++ b/jdk/src/macosx/classes/java/util/prefs/MacOSXPreferences.java	Tue Jul 24 13:38:50 2012 -0700
@@ -221,9 +221,14 @@
         // Flush should *not* check for removal, unlike sync, but should
         // prevent simultaneous removal.
         synchronized(lock) {
-            // fixme! overkill
-            if (!MacOSXPreferencesFile.flushWorld()) {
-                throw new BackingStoreException("Synchronization failed for node '" + path + "'");
+            if (isUser) {
+                if (!MacOSXPreferencesFile.flushUser()) {
+                    throw new BackingStoreException("Synchronization failed for node '" + path + "'");
+                }
+            } else {
+                if (!MacOSXPreferencesFile.flushWorld()) {
+                    throw new BackingStoreException("Synchronization failed for node '" + path + "'");
+                }
             }
         }
     }
--- a/jdk/src/macosx/classes/java/util/prefs/MacOSXPreferencesFile.java	Tue Jul 24 12:17:39 2012 -0700
+++ b/jdk/src/macosx/classes/java/util/prefs/MacOSXPreferencesFile.java	Tue Jul 24 13:38:50 2012 -0700
@@ -233,7 +233,23 @@
         return ok;
     }
 
-
+    //Flush only current user preferences
+    static synchronized boolean flushUser() {
+        boolean ok = true;
+        if (changedFiles != null  &&  !changedFiles.isEmpty()) {
+            Iterator<MacOSXPreferencesFile> iterator = changedFiles.iterator();
+            while(iterator.hasNext()) {
+                MacOSXPreferencesFile f = iterator.next();
+                if (f.user == cfCurrentUser) {
+                    if (!f.synchronize())
+                        ok = false;
+                    else
+                        iterator.remove();
+                }
+            }
+        }
+        return ok;
+    }
 
     // Write all prefs changes to disk, but do not clear all cached prefs
     // values. Also kills any scheduled flush task.
--- a/jdk/test/ProblemList.txt	Tue Jul 24 12:17:39 2012 -0700
+++ b/jdk/test/ProblemList.txt	Tue Jul 24 13:38:50 2012 -0700
@@ -384,8 +384,4 @@
 # 7041639, Solaris DSA keypair generation bug
 java/util/TimeZone/TimeZoneDatePermissionCheck.sh               solaris-all
 
-# 7150557
-java/util/prefs/RemoveReadOnlyNode.java                         macosx-all
-java/util/prefs/RemoveUnregedListener.java                      macosx-all
-
 ############################################################################