Skip to content

Conversation

@dyrpsf
Copy link

@dyrpsf dyrpsf commented Jan 9, 2026

Summary

This PR addresses sbmlteam/jsbml#255.

When a previously undefined double value (internally represented as NaN) is explicitly
set to NaN, no TreeNodeChangeListener event is fired. This happens because
firePropertyChange compares the old and new values using equals(), and for
Double.NaN, oldValue.equals(newValue) returns true, so no change is detected.

To fix this, the check in AbstractTreeNode.firePropertyChange is extended to also
consider reference inequality:

if ((oldValue == null) && (newValue != null)) {
  changeType = 0; // element added
} else if ((oldValue != null) && (newValue == null)) {
  changeType = 1; // element removed
} else if ((oldValue != null) &&
           (!oldValue.equals(newValue) || oldValue != newValue)) {
  changeType = 2; // real property change
}

This ensures that a property change event is fired even when equals() considers
the two values equal (e.g. NaN vs NaN), but the underlying objects differ.

Verification
Built JSBML and ran the core tests using:

mvn test -pl core -am

All jsbml-core tests pass, so the change does not introduce regressions
in the existing test suite.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant