On Tue, 3 Nov 2026 14:25:47 GMT, Daniel Fuchs <[email protected]> wrote:

> Please find here a fix for 8396058: 
> test/jdk/java/net/httpclient/http2/H2GoAwayPromptConnectionClose.java may 
> fail intermittently if responseSubscriber is still null when connection close 
> is processed
> The fix for [JDK-8394607](https://bugs.openjdk.org/browse/JDK-8394607) was 
> not fully complete, leaving a small window of opportunity for this additional 
> race condition.
> 
> The race can be easily reproduced by using 
> https://github.com/openjdk/jdk/pull/33697/changes/52c3114ecd048fb7914ae260f32a8471a7bd8c91
> 
> The final version of the fix removes the hacky offloading and `Thread.sleep` 
> that was used to trigger the bug reliably while working on the fix. So far, 
> and without the hacky sleep, I was able to observe the issue twice in the CI 
> before fixing. It's not very frequent but it does happen.
> 
> 
> ---------
> - [x] I confirm that I make this contribution in accordance with the [OpenJDK 
> Interim AI Policy](https://openjdk.org/legal/ai).

This problem is very difficult to understand, put aside verifying whether this 
band-aid over #33385 & [JDK-8394607] is complete.

[JDK-8394607]: https://bugs.openjdk.org/browse/JDK-8394607

src/java.net.http/share/classes/jdk/internal/net/http/Stream.java line 1542:

> 1540:     private boolean requestBodySuccessfullySent() {
> 1541:         if (requestPublisher == null) return true;
> 1542:         return requestBodyCF.isDone() && 
> !requestBodyCF.isCompletedExceptionally();

I think we need to amend this check for `requestContentLen == 0`:

Suggestion:

        return requestPublisher == null ||
                requestContentLen == 0 ||
                (requestBodyCF.isDone() && 
!requestBodyCF.isCompletedExceptionally());


I'll DM you a test reproducing this issue.

src/java.net.http/share/classes/jdk/internal/net/http/Stream.java line 1547:

> 1545:     void connectionClosing(Throwable cause) {
> 1546:         boolean runScheduler = false;
> 1547:         inputQLock.lock();

You may consider documenting the rationale for holding the `inputQLock` here.

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

PR Review: https://git.openjdk.org/jdk/pull/33697#pullrequestreview-5782814485
PR Review Comment: https://git.openjdk.org/jdk/pull/33697#discussion_r4479155720
PR Review Comment: https://git.openjdk.org/jdk/pull/33697#discussion_r4478851942

Reply via email to