RFR: 8314978: Multiple server call from connection failing with expect100 in getOutputStream

Daniel Jeliński djelinski at openjdk.org
Thu Aug 31 19:12:08 UTC 2023


On Wed, 30 Aug 2023 09:23:34 GMT, Vyom Tewari <vtewari at openjdk.org> wrote:

> With the current implementation of HttpURLConnection  if server rejects the  “Expect 100-continue” then there will be ‘java.net.ProtocolException’ will be thrown from 'expect100Continue()' method. 
> 
> After the exception thrown, If we call any other method on the same instance (ex getHeaderField(), or getHeaderFields()). They will internally call getOuputStream() which invokes writeRequests(), which make the actual server call.
> 
> The code change will sets the existing variable ‘rememberedException’ when there is exception and getOutputStream0() will re-throw ‘rememberedException’  if the ‘rememberedException’ is not null. 
> 
> Note: getOutputStream0() also call’s  ‘expect100Continue()’  if ‘expectContinue’ is true.

Looks reasonable.

test/jdk/java/net/HttpURLConnection/HttpURLConnectionExpect100Test.java line 70:

> 68: 
> 69:     @Test
> 70:     public void test() throws Exception {

Looks like it could be a parameterized test: with/without `Expect: 100-continue`, with `200` / `417` response. Either that, or add more descriptive names for the test methods.

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

PR Review: https://git.openjdk.org/jdk/pull/15483#pullrequestreview-1605500559
PR Review Comment: https://git.openjdk.org/jdk/pull/15483#discussion_r1312082426


More information about the net-dev mailing list