FULL PRODUCT VERSION :
java version "1.5.0_07"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_07-b03)
Java HotSpot(TM) Client VM (build 1.5.0_07-b03, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Linux dhcppc0 2.6.15-1-686 #2 Mon Mar 6 15:27:08 UTC 2006 i686 GNU/Linux
A DESCRIPTION OF THE PROBLEM :
The API documentation for java.util.prefs.Preferences.sync() states:
"Ensures that future reads from this preference node and its descendants reflect any changes that were committed to the persistent store (from any VM) prior to the sync invocation."
This is just not the case. After changing and flushing preferences in the first VM and calling sync() in the second the get(...) methods of the second VM will return old values for a long time (typically 30 seconds).
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run both programs of the test case side by side and look at the output.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Different values in the PreferencesListener program every secod.
ACTUAL -
The same values in the PreferencesListener program for half a minute after changing them.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
---------- the listener ----------
import java.util.prefs.*;
public class PreferencesListener {
public static void main(String[] args) throws Exception {
Preferences preferences = Preferences.userRoot().node("/test/synctest");
while (true) {
preferences.sync();
String value = preferences.get("key", null);
System.out.println("value: \"" + value + "\"");
Thread.sleep(1000);
}
}
}
---------- the writer ----------
import java.util.prefs.*;
public class PreferencesWriter {
public static void main(String[] args) throws Exception {
Preferences preferences = Preferences.userRoot().node("/test/synctest");
int counter = 0;
while (true) {
System.out.println("counter = " + counter++);
preferences.put("key", String.valueOf(counter));
preferences.flush();
Thread.sleep(1000);
}
}
}
---------- END SOURCE ----------
java version "1.5.0_07"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_07-b03)
Java HotSpot(TM) Client VM (build 1.5.0_07-b03, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Linux dhcppc0 2.6.15-1-686 #2 Mon Mar 6 15:27:08 UTC 2006 i686 GNU/Linux
A DESCRIPTION OF THE PROBLEM :
The API documentation for java.util.prefs.Preferences.sync() states:
"Ensures that future reads from this preference node and its descendants reflect any changes that were committed to the persistent store (from any VM) prior to the sync invocation."
This is just not the case. After changing and flushing preferences in the first VM and calling sync() in the second the get(...) methods of the second VM will return old values for a long time (typically 30 seconds).
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run both programs of the test case side by side and look at the output.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Different values in the PreferencesListener program every secod.
ACTUAL -
The same values in the PreferencesListener program for half a minute after changing them.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
---------- the listener ----------
import java.util.prefs.*;
public class PreferencesListener {
public static void main(String[] args) throws Exception {
Preferences preferences = Preferences.userRoot().node("/test/synctest");
while (true) {
preferences.sync();
String value = preferences.get("key", null);
System.out.println("value: \"" + value + "\"");
Thread.sleep(1000);
}
}
}
---------- the writer ----------
import java.util.prefs.*;
public class PreferencesWriter {
public static void main(String[] args) throws Exception {
Preferences preferences = Preferences.userRoot().node("/test/synctest");
int counter = 0;
while (true) {
System.out.println("counter = " + counter++);
preferences.put("key", String.valueOf(counter));
preferences.flush();
Thread.sleep(1000);
}
}
}
---------- END SOURCE ----------