On Sun, 3 Sep 2023 09:16:24 GMT, Vyom Tewari <[email protected]> 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.
>
> Vyom Tewari has updated the pull request incrementally with one additional 
> commit since the last revision:
> 
>   modified the junit tests names

I updated the code as per review comments.

1-> created a new variable ‘rememberedExceptionOut’ in place of reusing 
rememberedException’. Which eliminate the interaction between getOutputStream 
and getInputStream
2-> In current implementation,  ‘getInputStream()’  internally calls 
‘getOutputStream’ so if there is error in getOutputStream then calling 
getInputStream will throw exception. Which is same after the code change as 
well.

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

PR Comment: https://git.openjdk.org/jdk/pull/15483#issuecomment-1737159300

Reply via email to