The HTTP/2 test server in H2GoAwayPromptConnectionClose.java may buffer some 
frames when waiting for the SETTINGS frame ACK. It then expects to find or 
receive a HEADERS frame just after having obtained the connection settings. The 
client typically sends a WINDOW_UPDATE frame right after the SETTINGS frame. If 
that frame has been parsed and buffered by the server by the time we look for 
the HEADERS frames, everything works fine. However, if that frame is still 
sitting in the socket's buffer (or if it arrives later but before the HEADERS 
frame), then the server will fail, because it only expects to receive a HEADERS 
frame at this point.

This is timing sensitive, so the test passes most of the time. However from 
time to time the WINDOW_UPDATE frames comes a bit late, an exception is raised 
and ignored on the server side, the test fails in jtreg timeout and the log 
then shows:

[local=/127.0.0.1:51852, remote=/127.0.0.1:51858] received client preface
[local=/127.0.0.1:51852, remote=/127.0.0.1:51858] received SETTINGS frame
[local=/127.0.0.1:51852, remote=/127.0.0.1:51858] accumulating frames till a 
SETTINGS ACK frame is received
[local=/127.0.0.1:51852, remote=/127.0.0.1:51858] received frame type 4 
(SETTINGS)
[local=/127.0.0.1:51852, remote=/127.0.0.1:51858] completed exchanging SETTINGS 
frames between client and server
[local=/127.0.0.1:51852, remote=/127.0.0.1:51858] ignoring exception 
java.io.IOException: unexpected frame, got type 8, expected 1 that occurred 
when handling connection ...


Type 8 is the WINDOW_UPDATE frame type, type 1 is expected HEADERS frame type.

The fix is to relax the expectation in `expectFrame` and skip over 
WINDOW_UPDATE if it is received before the expected HEADERS frame.

---------
- [x] I confirm that I make this contribution in accordance with the [OpenJDK 
Interim AI Policy](https://openjdk.org/legal/ai).

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

Commit messages:
 - 8397538: 
test/jdk/java/net/httpclient/http2/H2GoAwayPromptConnectionClose.java should 
accept WINDOW_UPDATE while waiting for headers

Changes: https://git.openjdk.org/jdk/pull/33952/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=33952&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8397538
  Stats: 14 lines in 1 file changed: 7 ins; 0 del; 7 mod
  Patch: https://git.openjdk.org/jdk/pull/33952.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/33952/head:pull/33952

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

Reply via email to