RFR: 8081474: SwingWorker calls 'done' before the 'doInBackground' is finished [v3]

Alexey Ivanov aivanov at openjdk.org
Tue Jan 31 09:20:59 UTC 2023


On Tue, 31 Jan 2023 08:50:19 GMT, Prasanta Sadhukhan <psadhukhan at openjdk.org> wrote:

>> It seems the isDone method modification is causing a JCK test to fail and there's no spec for it to challenge JCK test, although logically it seems right that STATE should be DONE but for now, I have modified the fix which satisfies regression test and JCK both..
>
> isDone() spec mention `"Completion may be due to normal termination, an exception, or cancellation -- in all of these cases, this method will return true"`
> so for cancel state also, the state needs to be in DONE state, in which case we can reinstate the DONE state check in isDone()

`isDone()` spec is inherited from `Future.isDone()` and it is true for how `FutureTask` is implemented.

https://github.com/openjdk/jdk/blob/810c8a271b4524ae776e2306ef699e04a7d145a2/src/java.desktop/share/classes/javax/swing/SwingWorker.java#L565-L570

Can't we change it?

Given what is said in the spec for `SwingWorker` before, I assume `isDone` should return `true` when the status of `SwingWorker` moves to `DONE` and it should occur when `doInBackground` returns as this is defined in the spec:

https://github.com/openjdk/jdk/blob/810c8a271b4524ae776e2306ef699e04a7d145a2/src/java.desktop/share/classes/javax/swing/SwingWorker.java#L288-L293

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

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



More information about the client-libs-dev mailing list