Skip to content

Conversation

@AlanBateman
Copy link
Contributor

@AlanBateman AlanBateman commented Sep 19, 2025

Updates for JEP 525.

  • Joiner:onTimeout is added with join method changed to invoke this joiner method if
    a timeout is configured and the timeout expires before or while waiting. The onTimeout
    throws TimeoutException or may do nothing. This allows for Joiner implementation that
    are capable of returning a result from the subtasks that complete before the timeout expires.
  • The configFunction parameter to the 3-arg open is changed from
    Function<Configuration, Configuration> to UnaryOperator<Configuration>.
  • Subtask::get and Subtask::exception changed to consistently throw if called from
    any thread before the scope owner has joined.
  • StructuredTaskScope::join is now specified so that it may be called again if interrupted.
  • The parameter on Joiner::onFork and Joiner::onComplete is changed from
    Subtask<? extends T to Subtask<T>.
  • Joiner.allSuccessOrThrow is changed to return a list of results instead of a stream of
    subtasks. Joiner.allUntil is changed to return a list of subtasks.
  • Joiner.anySuccessfulResultOrThrow is renamed to anySuccessfulOrThrow.
  • Joiner.allUntil(Predicate) is changed to allow join return the stream of all forked
    subtasks when the timeout expires.
  • Joiner is no longer a @FunctionalInterface.

Most of the changes are to API docs and tests. Some links are changed to use double hash mark.


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change requires CSR request JDK-8367858 to be approved

Issues

  • JDK-8367857: Implement JEP 525: Structured Concurrency (Sixth Preview) (Enhancement - P3)
  • JDK-8367858: Implement JEP 525: Structured Concurrency (Sixth Preview) (CSR)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/27392/head:pull/27392
$ git checkout pull/27392

Update a local copy of the PR:
$ git checkout pull/27392
$ git pull https://git.openjdk.org/jdk.git pull/27392/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 27392

View PR using the GUI difftool:
$ git pr show -t 27392

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/27392.diff

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Sep 19, 2025

👋 Welcome back alanb! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link

openjdk bot commented Sep 19, 2025

❗ This change is not yet ready to be integrated.
See the Progress checklist in the description for automated requirements.

@openjdk openjdk bot added csr Pull request needs approved CSR before integration core-libs core-libs-dev@openjdk.org compiler compiler-dev@openjdk.org labels Sep 19, 2025
@openjdk
Copy link

openjdk bot commented Sep 19, 2025

@AlanBateman The following labels will be automatically applied to this pull request:

  • compiler
  • core-libs

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing lists. If you would like to change these labels, use the /label pull request command.

@AlanBateman
Copy link
Contributor Author

/label remove compiler

@openjdk openjdk bot removed the compiler compiler-dev@openjdk.org label Sep 19, 2025
@openjdk
Copy link

openjdk bot commented Sep 19, 2025

@AlanBateman
The compiler label was successfully removed.

@AlanBateman AlanBateman changed the title 8367857: Implement JEP xxx: Structured Concurrency (Sixth Preview) 8367857: Implement JEP 525: Structured Concurrency (Sixth Preview) Sep 23, 2025
@AlanBateman AlanBateman marked this pull request as ready for review September 24, 2025 08:47
@openjdk openjdk bot added the rfr Pull request is ready for review label Sep 24, 2025
@mlbridge
Copy link

mlbridge bot commented Sep 24, 2025

Webrevs

@pavelrappo
Copy link
Member

I haven't read the complete javadoc, but this jumped out at me in the diff: Cancallation as the id and the multiple references to it. It must be a typo.

@AlanBateman
Copy link
Contributor Author

I haven't read the complete javadoc, but this jumped out at me in the diff: Cancallation as the id and the multiple references to it. It must be a typo.

The API uses "cancellation" and is not changed in this update. The id (used for links) is indeed "Cancallation". A pre-existing issue and not introduced in this update. So well spotted. We can fix this.

@pavelrappo
Copy link
Member

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.

Why did you choose to add a namesake instead of an unchecked wrapper exception? Was it because you consider that the likelihood of mixing the two TimeoutException's is low in the context of a single file?

@AlanBateman
Copy link
Contributor Author

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.

It's better to bring API discussion to loom-dev, this PR is the refresh for JEP 525. A lot of time was spent in 2024 re-visiting all aspects of the API, including the use of checked exceptions.

@pavelrappo
Copy link
Member

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.

It's better to bring API discussion to loom-dev, this PR is the refresh for JEP 525. A lot of time was spent in 2024 re-visiting all aspects of the API, including the use of checked exceptions.

Thanks, done: https://mail.openjdk.org/pipermail/loom-dev/2025-October/007974.html

* successfully. Cancels the scope if any subtask fails.
*/
static final class AllSuccessful<T> implements Joiner<T, Stream<Subtask<T>>> {
static final class AllSuccessful<T> implements Joiner<T, List<T>> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be good to clear() the results onTimeout before throwing the TimeoutException.

Copy link
Contributor

@viktorklang-ora viktorklang-ora left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work, Alan!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core-libs core-libs-dev@openjdk.org csr Pull request needs approved CSR before integration rfr Pull request is ready for review

Development

Successfully merging this pull request may close these issues.

3 participants