[jdk17u-dev] Integrated: 8316580: HttpClient with StructuredTaskScope does not close when a task fails

Goetz Lindenmaier goetz at openjdk.org
Thu Jul 24 09:43:59 UTC 2025


On Mon, 7 Jul 2025 09:28:52 GMT, Goetz Lindenmaier <goetz at openjdk.org> wrote:

> 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 from 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(). Update: after some
> research this was further adapted.
> Finally I removed the "useReferenceTracker=false" test variant, as the
> HttpClient implementation is quite far off of the implementation in 21,
> so that the close() method implemented in 21 for Autoclosable can not
> be easily simulated in the test.
> 
> Original test compile error:
> 
> test/jdk/java/net/httpclient/HttpGetInCancelledFuture.java:239: error: cannot find symbol
>             pool.close();
>                 ^
>   symbol:   method close()
>   location: variable pool of type ExecutorService
> test/jdk/java/net/httpclient/HttpGetInCancelledFuture.java:249: error: incompatible types: try-with-resources not applicable to variable type
>         try (final var executor = testExecutor()) {
>                        ^
>     (ExecutorService cannot be converted to AutoCloseable)
> test/jdk/java/net/httpclient/HttpGetInCancelledFuture.java:277: error: incompatible types: Tracker cannot be converted to StringBuilder
>                     System.out.println(TRACKER.diagnose(tracker));
>                                                         ^
> test/jdk/java/net/httpclient/HttpGetInCancelledFuture.java:293: error: cannot find symbol
>                     httpClient.close();
>                               ^
>   symbol:   method close()
>   location: variable httpClient of type HttpClient

This pull request has now been integrated.

Changeset: bbbe85c8
Author:    Goetz Lindenmaier <goetz at openjdk.org>
URL:       https://git.openjdk.org/jdk17u-dev/commit/bbbe85c8dadf6dacbb8d7690668dedd4ad9357b4
Stats:     504 lines in 4 files changed: 480 ins; 10 del; 14 mod

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

Reviewed-by: abakhtin, phh
Backport-of: d8291f593762ab270bf05643b87c57578d716242

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

PR: https://git.openjdk.org/jdk17u-dev/pull/3706


More information about the jdk-updates-dev mailing list