StructuredTaskScope.TimeoutException vs UncheckedTimeoutException
Alan Bateman
alan.bateman at oracle.com
Wed Oct 22 06:26:45 UTC 2025
On 21/10/2025 13:50, Pavel Rappo wrote:
> As suggested in a PR thread [*], I bring this question to loom-dev:
>
> I haven't been paying much attention to the recent previews of this
> feature, so feel free to point me to a relevant discussion elsewhere.
>
> As I understand it, an unchecked StructuredTaskScope.TimeoutException
> was added in JDK 25. There's also the well-known checked
> java.util.TimeoutException. I assume that the namesake exception was
> added solely because it's unchecked. I also assume
> UncheckedTimeoutException was considered at some stage, because in my
> mind, the situation is similar to that of
> IOException/UncheckedIOException.
If a timeout is configured when opening a new StructuredTaskScope then
it applies to the scope. If the timeout expires before the scope is
closed then the timeout causes the scope to be cancelled and join to
wakeup. Declaring join to throw the checked-TimeoutException would be
very annoying when not using a timeout or in the update, when there is
other outcome when the timeout expires.
One of these years, there will be progress on the topic of exception
transparency. It's impossible to know how this might look but there is a
good chance that it will shine a light on past decisions to introduce
UncheckedXXX exceptions. Introducing UncheckedTimeoutException would
invite more usages, way beyond the very specific need here.
-Alan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/loom-dev/attachments/20251022/10c4695a/attachment-0001.htm>
More information about the loom-dev
mailing list