-
Enhancement
-
Resolution: Not an Issue
-
P4
-
None
-
1.4.0, 6, 6u10
-
x86
-
linux, windows_xp
Name: gm110360 Date: 10/15/2002
FULL PRODUCT VERSION :
java version "1.4.1"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1-b21)
Java HotSpot(TM) Client VM (build 1.4.1-b21, mixed mode)
FULL OPERATING SYSTEM VERSION :
Microsoft Windows XP [Version 5.1.2600]
A DESCRIPTION OF THE PROBLEM :
The API documentation for the
java.beans.PropertyChangeSupport.firePropertyChange(...)
methods states that:
"No event is fired if old and new are equal and non-null."
This causes a bogus event to be fired if both old and new
are null.
The current sematics therefore makes it impossible to
solely rely on the event devliery mechanism to detect
property changes. One must check that the delivered event
really describes a change.
EXPECTED VERSUS ACTUAL BEHAVIOR :
The expected result is that the test program creates no
output.
Insead the following is produced:
oldValue=null
newValue=null
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
public class PropertyChangeTest implements java.beans.PropertyChangeListener {
PropertyChangeTest() {
java.beans.PropertyChangeSupport p = new
java.beans.PropertyChangeSupport(this);
p.addPropertyChangeListener( this );
p.firePropertyChange( "dummy", null, null );
p.firePropertyChange( "dummy", "hello", "hello" );
}
public void propertyChange( java.beans.PropertyChangeEvent event ) {
System.err.println( "oldValue="+event.getOldValue() );
System.err.println( "newValue="+event.getNewValue() );
}
public static void main(String[] args) {
new PropertyChangeTest();
}
}
---------- END SOURCE ----------
CUSTOMER WORKAROUND :
Change the listeners to check for oldValue == newValue.
public void propertyChange( PropertyChangeEvent event ) {
if ( event.getOldValue() == null
&& event.getNewValue() == null )
{
return;
}
// ...
}
(Review ID: 165789)
======================================================================
- duplicates
-
JDK-6967462 AbstractAction firePropertyChange fires when oldValue == newValue == null
-
- Closed
-
-
JDK-6587164 PropertyChangeSupport do not detect null change
-
- Closed
-
- relates to
-
JDK-4897238 JFormattedTextField fires PropertyChangeEvent twice during setValue
-
- Resolved
-