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

Alexey Ivanov aivanov at openjdk.org
Thu Feb 2 21:09:27 UTC 2023


On Thu, 2 Feb 2023 21:04:20 GMT, Sergey Bylokhov <serb at openjdk.org> wrote:

> > Why do you think so?
> > The `done` method hasn't thrown `CancellationException`, and it will not. If it had thrown the exception, Prasanta's test would've caught it.
> 
> But the `done` methods which call "get" will start to throw that exception, right? Implementation of "done" method in the jconsole actually calls "get". Is that pattern could be common?

`done` which calls `get` **will *continue*** to see this exception: nothing has changed. As soon as `cancel` is called, `get` throws `CancellationException` (unless `doInBackground` completed by that time). The old code threw the exception just like the new one does.

You can take Prasanta's test and add a call to `get` into `done` — it throws `CancellationException` if run with jdk19 or 21 without the fix. It still throws `CancellationException` with the fix. (I've just done it to confirm my own sanity. You can do it too.)

Nothing has changed in this regard.

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

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



More information about the client-libs-dev mailing list