mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-23 20:44:41 +02:00
7118100: (prefs) Inconsistency when using system and user preference on OSX Lion
Enable user to read/write preferences to persistent storage Reviewed-by: alanb
This commit is contained in:
parent
6d834825de
commit
c53c258233
2 changed files with 41 additions and 2 deletions
|
@ -231,8 +231,14 @@ class MacOSXPreferences extends AbstractPreferences {
|
|||
if (isRemoved())
|
||||
throw new IllegalStateException("Node has been removed");
|
||||
// fixme! overkill
|
||||
if (!MacOSXPreferencesFile.syncWorld()) {
|
||||
throw new BackingStoreException("Synchronization failed for node '" + path + "'");
|
||||
if (isUser) {
|
||||
if (!MacOSXPreferencesFile.syncUser()) {
|
||||
throw new BackingStoreException("Synchronization failed for node '" + path + "'");
|
||||
}
|
||||
} else {
|
||||
if (!MacOSXPreferencesFile.syncWorld()) {
|
||||
throw new BackingStoreException("Synchronization failed for node '" + path + "'");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -192,6 +192,39 @@ class MacOSXPreferencesFile {
|
|||
}
|
||||
|
||||
|
||||
// Sync only current user preferences
|
||||
static synchronized boolean syncUser() {
|
||||
boolean ok = true;
|
||||
if (cachedFiles != null && !cachedFiles.isEmpty()) {
|
||||
Iterator<WeakReference> iter = cachedFiles.values().iterator();
|
||||
while (iter.hasNext()) {
|
||||
WeakReference ref = iter.next();
|
||||
MacOSXPreferencesFile f = (MacOSXPreferencesFile)ref.get();
|
||||
if (f != null && f.user == cfCurrentUser) {
|
||||
if (!f.synchronize()) {
|
||||
ok = false;
|
||||
}
|
||||
} else {
|
||||
iter.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
// Remove synchronized file from changed file list. The changed files were
|
||||
// guaranteed to have been in the cached file list (because there was a strong
|
||||
// reference from changedFiles.
|
||||
if (changedFiles != null) {
|
||||
Iterator<MacOSXPreferencesFile> iterChanged = changedFiles.iterator();
|
||||
while (iterChanged.hasNext()) {
|
||||
MacOSXPreferencesFile f = iterChanged.next();
|
||||
if (f != null && f.user == cfCurrentUser)
|
||||
iterChanged.remove();
|
||||
}
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Write all prefs changes to disk, but do not clear all cached prefs
|
||||
// values. Also kills any scheduled flush task.
|
||||
// There's no CFPreferencesFlush() (<rdar://problem/3049129>), so lots of cached prefs
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue