-
Bug
-
Resolution: Duplicate
-
P3
-
None
-
6u10
-
x86
-
windows_xp
FULL PRODUCT VERSION :
A DESCRIPTION OF THE PROBLEM :
If the newValue of the property is null, and the oldValue of the property is null, the property has not changed. You test for .equals() but the code
if (changeSupport == null ||
(oldValue != null && newValue != null && oldValue.equals(newValue))) {
return;
}
changeSupport.firePropertyChange(propertyName, oldValue, newValue);
misses the case where newValue==oldValue==null
I cannot think of a use case where you'd want to fire a property change in this context for a property has not changed. I'm dealing with a lot of Actions extending AbstractAction, and see tons of extraneous, unnecessary property change events being fired when no property values have actually changed.
A simple fix would be to just include && oldValue == newValue as part of the if statement, ie.:
if (changeSupport == null ||
(oldValue != null && newValue != null && oldValue.equals(newValue)) ||
oldValue == newValue)
{
return;
}
REPRODUCIBILITY :
This bug can be reproduced always.
CUSTOMER SUBMITTED WORKAROUND :
Override firePropertyChange in the AbstractAction subclass to implement this fix.
A DESCRIPTION OF THE PROBLEM :
If the newValue of the property is null, and the oldValue of the property is null, the property has not changed. You test for .equals() but the code
if (changeSupport == null ||
(oldValue != null && newValue != null && oldValue.equals(newValue))) {
return;
}
changeSupport.firePropertyChange(propertyName, oldValue, newValue);
misses the case where newValue==oldValue==null
I cannot think of a use case where you'd want to fire a property change in this context for a property has not changed. I'm dealing with a lot of Actions extending AbstractAction, and see tons of extraneous, unnecessary property change events being fired when no property values have actually changed.
A simple fix would be to just include && oldValue == newValue as part of the if statement, ie.:
if (changeSupport == null ||
(oldValue != null && newValue != null && oldValue.equals(newValue)) ||
oldValue == newValue)
{
return;
}
REPRODUCIBILITY :
This bug can be reproduced always.
CUSTOMER SUBMITTED WORKAROUND :
Override firePropertyChange in the AbstractAction subclass to implement this fix.
- duplicates
-
JDK-4763463 PropertyChangeSupport.firePropertyChange() notifies when oldVal == newVal ==null
-
- Closed
-
- relates to
-
JDK-6587164 PropertyChangeSupport do not detect null change
-
- Closed
-
-
JDK-6291808 firePropertyChange fires contrary to API specification
-
- Closed
-