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

PropertyChangeSupport do not detect null change

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Duplicate
    • Icon: P5 P5
    • None
    • 6
    • client-libs

      A DESCRIPTION OF THE REQUEST :
      PropertyChangeSupport.firePropertyChange(String propertyName, Object oldValue, Object newValue) fires PropertyChange when both values are null. This is not real change and should not firePropertyChange.

      JUSTIFICATION :
      Avoid infinite loops and StackOverflowException.

      ACTUAL -
          /**
           * Report a bound property update to any registered listeners.
           * No event is fired if old and new are equal and non-null.
           *
           * <p>
           * This is merely a convenience wrapper around the more general
           * firePropertyChange method that takes {@code
           * PropertyChangeEvent} value.
           *
           * @param propertyName The programmatic name of the property
           * that was changed.
           * @param oldValue The old value of the property.
           * @param newValue The new value of the property.
           */
          public void firePropertyChange(String propertyName,
      Object oldValue, Object newValue) {
      if (oldValue != null && newValue != null && oldValue.equals(newValue)) {
      return;
      }
      firePropertyChange(new PropertyChangeEvent(source, propertyName,
      oldValue, newValue));
          }

      ---------- BEGIN SOURCE ----------
      if (oldValue != null && newValue != null && oldValue.equals(newValue)) {
      return;
      }

      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      if (oldValue == null) {
          if (newValue == null) return;
      } else {
          if (oldValue.equals(newValue)) return;
      }

            malenkov Sergey Malenkov (Inactive)
            ndcosta Nelson Dcosta (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: