RFR: 8303481: CancelRequestTest assertTrue failing with AssertionError due to java.util.concurrent.CompletionException: java.io.EOFException: EOF reached while reading

Daniel Fuchs dfuchs at openjdk.org
Fri Mar 3 09:50:01 UTC 2023


Please find here a fix that address a robustness issue in our test HTTP/2 server.

Somewhat unrelated to the issue - but making the debug log easier to read - I changed the toString() of OutgoingHeaders to be more meaningful. OutgoingHeaders is a synthetic frame - the toString of the parent class was making it appear as an UNKNOWN frame - which was confusing.

The CancelRequestTest has been observed failing intermittently with this exception:
Got expected exception: java.util.concurrent.ExecutionException: java.io.EOFException: EOF reached while reading
cancelled [jdk.internal.net.http.common.MinimalFuture at 3564a02c]jdk.internal.net.http.common.MinimalFuture at 3564a02c)[Completed exceptionally: java.util.concurrent.CompletionException: java.io.EOFException: EOF reached while reading] (id=6669)
test CancelRequestTest.testPostSendAsync("http://localhost:49317/http2/x/same/interrupt", true, true): failure
java.lang.AssertionError: expected [true] but found [false]
at org.testng.Assert.fail(Assert.java:99)
at org.testng.Assert.failNotEquals(Assert.java:1037)
at org.testng.Assert.assertTrue(Assert.java:45)
at org.testng.Assert.assertTrue(Assert.java:55)
at CancelRequestTest.testPostSendAsync(CancelRequestTest.java:453)

Analysis of the logs shows that this is due to the Http2TestServer closing the associated connection after failing to queue up a frame for the previously cancelled stream in its connection readLoop. The frame could not be queued because the previous stream was already closed.

DEBUG: [pool-1-thread-4] [10s 773ms] Http2Connection(SocketTube(19)) Closed stream 27
Sent response headers 200
DEBUG: [readLoop] [10s 773ms] FramesDecoder decodes: 9
DEBUG: [readLoop] [10s 773ms] FramesDecoder Tail size is now: 0, current=
DEBUG: [readLoop] [10s 773ms] FramesDecoder Got frame: DATA: length=0, streamid=27, flags=END_STREAM
DEBUG: [readLoop] [10s 773ms] FramesDecoder decodes: 0
DEBUG: [readLoop] [10s 773ms] FramesDecoder Tail size is now: 0, current=
java.io.IOException: closed
at jdk.httpclient.test.lib.http2.BodyOutputStream.write(BodyOutputStream.java:84)
at java.base/java.io.OutputStream.write(OutputStream.java:124)
at CancelRequestTest$HTTPSlowHandler.handle(CancelRequestTest.java:676)
at jdk.httpclient.test.lib.common.HttpServerAdapters$HttpChain$Http2Chain.doFilter(HttpServerAdapters.java:476)
at jdk.httpclient.test.lib.common.HttpServerAdapters$HttpTestServer$Http2TestContext.handle(HttpServerAdapters.java:746)
at jdk.httpclient.test.lib.common.HttpServerAdapters$HttpTestHandler.doHandle(HttpServerAdapters.java:395)
at jdk.httpclient.test.lib.common.HttpServerAdapters$HttpTestHandler.lambda$toHttp2Handler$1(HttpServerAdapters.java:382)
at jdk.httpclient.test.lib.http2.Http2TestServerConnection.handleRequest(Http2TestServerConnection.java:721)
at jdk.httpclient.test.lib.http2.Http2TestServerConnection.lambda$createStream$4(Http2TestServerConnection.java:671)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:577)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
at java.base/java.lang.Thread.run(Thread.java:1623)
Http server reader thread shutdown
java.io.IOException: stream closed
at jdk.httpclient.test.lib.http2.Queue.put(Queue.java:64)
at jdk.httpclient.test.lib.http2.Http2TestServerConnection.readLoop(Http2TestServerConnection.java:833)
at jdk.httpclient.test.lib.http2.Http2TestServerConnection$ConnectionThread.run(Http2TestServerConnection.java:466)

The readLoop should be more robust to asynchronous closing of HTTP/2 stream, and just drop the frame if the stream is already closed.

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

Commit messages:
 - 8303481

Changes: https://git.openjdk.org/jdk/pull/12850/files
 Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=12850&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8303481
  Stats: 23 lines in 3 files changed: 21 ins; 1 del; 1 mod
  Patch: https://git.openjdk.org/jdk/pull/12850.diff
  Fetch: git fetch https://git.openjdk.org/jdk pull/12850/head:pull/12850

PR: https://git.openjdk.org/jdk/pull/12850


More information about the net-dev mailing list