Skip to content

[#1208] Read the request body in the redirecting test servers of openam-certs, so that a POST to them no longer fails at random on Windows with JDK 11 - #1209

Merged
vharseko merged 1 commit into
OpenIdentityPlatform:masterfrom
vharseko:issues/crl-dp-test-drain-request-body
Oct 28, 2026
Merged

vharseko merged 1 commit into
OpenIdentityPlatform:masterfrom
vharseko:issues/crl-dp-test-drain-request-body

Conversation

@vharseko

Copy link
Copy Markdown
Member

Problem

AMCRLStoreDpFetchTest.theParametersDroppedAtASeeOtherStayDroppedForTheRestOfTheChain fails at random in build-maven (windows-latest, 11) with but was: null (master run 39647411735, attempt 2; #1201 run 40639954288).

The test POSTs to TestHttpServer.redirectTo, which answers with sendResponseHeaders(status, -1) without reading the request body. On JDK 11 the server does not drain the body in that case, and closes the connection with the body still unread, which resets it. On Windows the reset discards the response the client has already received. JDK 17 and later drain the body there.

Changes

  • TestHttpServer.redirectTo and redirectAfter read the request body before answering. Every test that POSTs to a redirector goes through one of them.

Verification

  • A probe on macOS sends the request headers and the body in two writes, as HttpURLConnection does, to a handler that answers 303 with -1:
JDK 11 JDK 17
body not read (master) Connection reset after the response connection kept alive
body read (this change) connection kept alive connection kept alive

macOS hands over the response before the reset, so the failure itself does not reproduce there; it has been seen only on windows-latest with JDK 11, in the two runs above.

  • mvn -pl openam-certs test with JDK 11: 148 tests, 0 failures.

Fixes #1208

…test servers of openam-certs, so that a POST to them no longer fails at random on Windows with JDK 11

On JDK 11 a response sent with no body leaves the request body unread, and
the server closes the connection over it with a reset. On Windows the reset
discards the response the fetcher has already received, so the POST to the
redirector in AMCRLStoreDpFetchTest returned null at random.
@vharseko
vharseko requested a review from maximthomas October 28, 2026 06:54
@vharseko vharseko added tests Test suite: coverage, fixtures, or test infrastructure windows java Pull requests that update java code labels Oct 28, 2026

@maximthomas maximthomas left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

praise: The drain sits exactly where the reset comes from, and it reaches every test that POSTs to a redirector.

  • TestHttpServer.redirectTo(int, String) and redirectAfter now read the body before sendResponseHeaders(status, -1). A raw-socket probe on JDK 11.0.25 shows the effect: after a 303 to an unread POST the server closes the connection (second request: Broken pipe, 3/3). Once the body is read, the connection stays open. The source agrees: ExchangeImpl queues WriteFinishedEvent on the -1 path, and ServerImpl closes the connection when !is.isEOF().
  • Every POST to a redirector in AMCRLStoreDpFetchTest (storeWithUriParams, lines 387-482, including the two wrapped in recording(...)) goes through redirectTo. The two inline 302 handlers at lines 181-205 only ever get body-less GETs from newStore().

@vharseko
vharseko merged commit 47737d8 into OpenIdentityPlatform:master Oct 28, 2026
24 of 25 checks passed
@vharseko
vharseko deleted the issues/crl-dp-test-drain-request-body branch October 28, 2026 09:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

java Pull requests that update java code tests Test suite: coverage, fixtures, or test infrastructure windows

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AMCRLStoreDpFetchTest fails at random on Windows with JDK 11

2 participants