ADDITIONAL SYSTEM INFORMATION :
Linux-x64, Alpine Linux, musl, openjdk-11 build 28
A DESCRIPTION OF THE PROBLEM :
java.net.http.HttpClient does not provide response (status 204) until 1 minute has passed. This appears to correlate with some sort of keep-alive or timeout configuration and not with response time from http server.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
The following steps requires that docker is installed:
1. $ git clone https://github.com/kimcs/javanethttp204bug.git
2. $ cd javanethttp204bug
3. $ docker build -t javanethttp204bug .
4. $ docker run -it javanethttp204bug
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Expected all http requests to respond within at most a few milliseconds, including the response with status-code 204.
ACTUAL -
A 1 minute wait-time to recognize the 204 response. Standard out produce a "TEST FAILED" line at the very end.
---------- BEGIN SOURCE ----------
https://github.com/kimcs/javanethttp204bug
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Either of the following are workarounds:
1. Not using musl linked JDK 11 for Alpine Linux distributions, rather use JDK 11 linked to normal glibc.
2. Not using 204 response code in your http-server application. E.g. use 200 instead.