Skip to content

8316580: HttpClient with StructuredTaskScope does not close when a task fails #3706

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

GoeLin
Copy link
Member

@GoeLin GoeLin commented Jul 7, 2025

I backport this for parity with 17.0.17-oracle.

The change applies clean, but the test does not work out-of-the-box.

It calls some utility methods ReferenceTracker.java that were added by JDK-8305847.
That change is not in the current list of backports, so I added the utility methods
to this change.

Further, the test depends on the fact that in 21 a row of classes implement
AutoClosable, which they don't do in 21.
I adapted a row of places to work around this.
A try-with-resources statement was easy to replace, as the missing
close() implementation uses public methods, so that I could copy the
code to the test.
In TestTaskScope I replaced close() by shutdownNow().
Finally I removed the "useReferenceTracker=false" test variant, as the
HttpClient implementation is quite far off of the implementation in 21.


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
  • JDK-8316580 needs maintainer approval

Issue

  • JDK-8316580: HttpClient with StructuredTaskScope does not close when a task fails (Bug - P4)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk17u-dev.git pull/3706/head:pull/3706
$ git checkout pull/3706

Update a local copy of the PR:
$ git checkout pull/3706
$ git pull https://git.openjdk.org/jdk17u-dev.git pull/3706/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 3706

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

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk17u-dev/pull/3706.diff

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Jul 7, 2025

👋 Welcome back goetz! 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 Jul 7, 2025

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

@openjdk openjdk bot changed the title Backport d8291f593762ab270bf05643b87c57578d716242 8316580: HttpClient with StructuredTaskScope does not close when a task fails Jul 7, 2025
@openjdk
Copy link

openjdk bot commented Jul 7, 2025

This backport pull request has now been updated with issue from the original commit.

@openjdk openjdk bot added the backport Port of a pull request already in a different code base label Jul 7, 2025
@GoeLin GoeLin marked this pull request as ready for review July 8, 2025 06:50
@openjdk openjdk bot added the rfr Pull request is ready for review label Jul 8, 2025
@mlbridge
Copy link

mlbridge bot commented Jul 8, 2025

Webrevs

@GoeLin
Copy link
Member Author

GoeLin commented Jul 9, 2025

GHA failure: unrelated.
Error: Failed to FinalizeArtifact: Unable to make request: ECONNRESET

@openjdk
Copy link

openjdk bot commented Jul 9, 2025

⚠️ @GoeLin This change is now ready for you to apply for maintainer approval. This can be done directly in each associated issue or by using the /approval command.

@GoeLin
Copy link
Member Author

GoeLin commented Jul 10, 2025

I pushed an extra change to the test.
It replaces the shutdownNow() by more graceful coding.
This seems to better imitate the behavior of the original test.
Unfortunately with this change the test hangs until it is killed by jtreg (see attachted jtr file).
It only passes if run with the debug build, and once passed in our nightlies with the fastdebug.
I copied the modified test into my jdk21 repo where it passes as expected. Thus we think there is an issue with the backport in jdk, or the test unveils a further issue with the http implementation in 17.

HttpGetInCancelledFuture-stripped.jtr.txt

@GoeLin
Copy link
Member Author

GoeLin commented Jul 11, 2025

Hi @dfuch, @wxiao @djelinski
Could you please have a look at this backport? It seems I have missed something. The problem I describe on the comment above sounds a lot as if the original problem, not decrementing the refcount, still exists.
Obviously this backport is tricky as 17 lacks the virtual threads...
I would appreciate your help.
(I guessed the github name of you, Weibing Xiao. Maybe it works.)

@djelinski
Copy link
Member

Hi @GoeLin, that's a different problem here; looking at the thread dump in the jtr file, you can see that the ForkJoinPool tasks are still running. Apparently cancel(true) does not interrupt the threads in JDK 17. I suppose the threads need to be interrupted explicitly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport Port of a pull request already in a different code base rfr Pull request is ready for review
Development

Successfully merging this pull request may close these issues.

3 participants