**Issue**
It was observed that when the httpclient sends a POST request with the `Expect: 
100 Continue` header set and the server replies with a response code `417 
Expectation Failed` that the httpclient hangs indefinitely when the version of 
Http used is HTTP/2. However, it was also seen that the issue persisted with 
HTTP/1_1 with the same usage.

This was caused by an implementation in ExchangeImpl that resulted in two calls 
to readBodyAsync() in this case, where the second call causes the indefinite 
hanging (as if there was a respomse body, it has already been read).

**Solution**
When ExchangeImpl::expectContinue() detects that a response code 417 is 
received, two things occur. Firstly, a flag is set which ensures that the 
connection is closed locally in this case. Secondly, the response is returned 
to the client as a failed future, A unit test was added to ensure that this 
usage of the httpclient does not cause hanging.

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

Commit messages:
 - 8286171: Added bug id
 - 8286171: HttpClient/2 : Expect:100-Continue blocks indefinitely when 
response is not 100

Changes: https://git.openjdk.java.net/jdk/pull/9093/files
 Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=9093&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8286171
  Stats: 302 lines in 6 files changed: 299 ins; 0 del; 3 mod
  Patch: https://git.openjdk.java.net/jdk/pull/9093.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/9093/head:pull/9093

PR: https://git.openjdk.java.net/jdk/pull/9093

Reply via email to