Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6967462

AbstractAction firePropertyChange fires when oldValue == newValue == null

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P3 P3
    • None
    • 6u10
    • client-libs

      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.

            malenkov Sergey Malenkov (Inactive)
            igor Igor Nekrestyanov (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: