On Tue, 31 Jan 2023 12:34:27 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 update

Changes requested by aivanov (Reviewer).

test/jdk/javax/swing/SwingWorker/TestDoneBeforeDoInBackground.java line 37:

> 35: 
> 36:     static boolean doInBackground = false;
> 37:     static final int WAIT_TIME = 200;

Why not `private`?

test/jdk/javax/swing/SwingWorker/TestDoneBeforeDoInBackground.java line 87:

> 85:             throw new RuntimeException("doInBackground is finished " +
> 86:                                        " but State is not DONE");
> 87:         }

I think you should wait for cleanup to finish and ensure that `doInBackground` 
is set to `true` and the state is `DONE`.

If you don't wait until cleanup wait completes, the test does not test anything 
because jtreg will shutdown the JVM as soon main thread exists, which will 
happen before `done` gets called.

-------------

PR: https://git.openjdk.org/jdk/pull/11940

Reply via email to