7184287: (prefs) BackingStoreException when calling flush on root node[macosx]

Change implementation to enable user without administrative privileges to call flush

Reviewed-by: alanb
This commit is contained in:
Kurchi Subhra Hazra 2012-07-24 13:38:50 -07:00
parent b9fa2e4fb9
commit 9b4da3fa50
3 changed files with 25 additions and 8 deletions

View File

@ -221,12 +221,17 @@ class MacOSXPreferences extends AbstractPreferences {
// Flush should *not* check for removal, unlike sync, but should
// prevent simultaneous removal.
synchronized(lock) {
// fixme! overkill
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 + "'");
}
}
}
}
// AbstractPreferences implementation
@Override

View File

@ -233,7 +233,23 @@ class MacOSXPreferencesFile {
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.

View File

@ -384,8 +384,4 @@ java/util/concurrent/locks/ReentrantLock/CancelledLockLoops.java generic-all
# 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
############################################################################