Name: nt126004 Date: 10/09/2002
FULL PRODUCT VERSION :
java version "1.4.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-b92)
Java HotSpot(TM) Client VM (build 1.4.0-b92, mixed mode)
FULL OPERATING SYSTEM VERSION :
Kernel 2.4.18
RedHat 7.2
glibc-2.2.4-13
ADDITIONAL OPERATING SYSTEMS :
A DESCRIPTION OF THE PROBLEM :
PreferencesChangeListners are not notified when a second JVM
changes Preferences. Although the changes show up after 30
seconds or if you call sync() on the node in question. So the
nodes preferences change without every firing off the Change
listners.
In 1.4.1 it still does not work. The change appears, but no
PreferenceChangeEvent is fired.
So basically the current implementation sees the change made by the other JVM,
it just does not fire the event.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1.Add a Preferences change listner to a Prefernces node.
2.Change a Preference on that node from a second JVM
3.The PreferenceChangeListner Will not fire
4. sync() that node
5. The PreferenceChangeListener will not fire.
6. The change will be there if you access the node
Using the provided example run Listener from one jvm
and then run Changer from another
EXPECTED VERSUS ACTUAL BEHAVIOR :
If the value of a Preference changes for a node I expect that
the ChangeListeners would fire. The code knows to make the
changes but does not fire the listener. Her is the output of
running the Listener and Changer program:
[localhost - 13:25:40] PrefBug$ java Listener
Got Preferences change
eventjava.util.prefs.PreferenceChangeEvent[source=User
Preference Node: /Listen]
changed = no
changed = no
changed = no
changed = no
changed = no
changed = yes
Since the Listener.java sees the change in value the
PreferenceChangeEvent should fire.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
FILE: Listener.java
import java.util.prefs.*;
public class Listener implements PreferenceChangeListener {
public void preferenceChange( PreferenceChangeEvent e ) {
// we don't care what the event is just compleatly reconfigure
System.out.println( "Got Preferences change event" + e );
}
public static void main( String [] argv ) throws Exception {
Preferences node = Preferences.userRoot().node( "/Listen" );
node.addPreferenceChangeListener( new Listener() );
node.put( "changed", "no" );
while( true ) {
// wait for a change
Thread.sleep( 5000 );
node.sync();
System.out.println( "changed = " + node.get( "changed", "default" )
);
}
}
}
FILE Changer.java
import java.util.prefs.*;
public class Changer {
public static void main( String [] argv ) throws Exception {
Preferences node = Preferences.userRoot().node( "/Listen" );
node.put( "changed", "yes" );
node.sync();
}
}
---------- END SOURCE ----------
(Review ID: 164964)
======================================================================