On Fri, 10 Feb 2023 16:46:24 GMT, Prasanta Sadhukhan <psadhuk...@openjdk.org> wrote:
>> SwingWorker done() method [spec >> ](https://github.com/openjdk/jdk/blob/master/src/java.desktop/share/classes/javax/swing/SwingWorker.java#L452) >> says "Executed on the Event Dispatch Thread after the doInBackground method >> is finished" >> but there's no mechanism in place to honor that claim. >> The >> [spec](https://github.com/openjdk/jdk/blob/master/src/java.desktop/share/classes/javax/swing/SwingWorker.java#L289) >> also says the state should be DONE after doInBackground() returns which is >> also not done. >> >> Modified the code to honour the specification. > > Prasanta Sadhukhan has updated the pull request incrementally with one > additional commit since the last revision: > > Test alignment Should `evt.getNewValue()` be used to identify the new value of the state property? The test does not fail if I change the order of the lines in the `finally` block that reverses the order in which the `done` method is called and listeners are notified. I expected it to fail. Isn't it the reason why `PropertyChangeListener` was added? test/jdk/javax/swing/SwingWorker/TestDoneBeforeDoInBackground.java line 103: > 101: "PropertyChangeListeners called with " + > 102: "state STARTED before doInBackground is > finished"); > 103: } The comments, conditions and error messages do not match. In the first case, it should be `doInBackgroundStarted` instead of `doInBackgroundFinished`; in the second — `doInBackgroundFinished` correspondingly. Or the error messages should be swapped. Did you mean anything else? ------------- Changes requested by aivanov (Reviewer). PR: https://git.openjdk.org/jdk/pull/11940