<Swing Dev> [11] Review Request: JDK-6562442: JList.setModel() may silently fail if ListModel.equals() returns true
Pankaj Bansal
pankaj.b.bansal at oracle.com
Tue Feb 6 10:22:11 UTC 2018
Hi All,
Please review the fix for JDK 11.
Bug:
https://bugs.openjdk.java.net/browse/JDK-6562442
webrev:
http://cr.openjdk.java.net/~pbansal/6562442/webrev.00/
Issue:
JList may not set ListModel properly on calling JList.setModel in some cases.
The ListModel should be checked for equality by reference not by actual values, while calling JList.setModel. JList.setModel informs the UI delegate about the change by firing a propertyChange. Now firePropertyChange checks for equality between the models by calling equals. This may return a false true, if a subclass of ListModel has overridden the equals method to test the ListModels for actual values for some other purpose. This may leave UI delegate in inconsistent state.
Fix:
Made changes in JList.setModel to check for equality by reference and then call firePropertyChange. In first call to firePropertyChange, newValue is sent as null, so that ListDataListeners are removed from the old ListModel. Then new ListModel is set.
In test, for automation, the check is added on number of ListDataListeners in ListModel as JList.setModel should remove the listeners from old model and add to new model.
Regards,
Pankaj Bansal
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/swing-dev/attachments/20180206/271bdf2d/attachment.html>
More information about the swing-dev
mailing list