PropertyChangeSupport do not detect null change

XMLWordPrintable

    • Type: Enhancement
    • Resolution: Duplicate
    • Priority: P5
    • None
    • Affects Version/s: 6
    • Component/s: 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;
      }

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

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: