-
Bug
-
Resolution: Fixed
-
P4
-
8, 11, 17, 20, 21
-
b19
-
generic
-
generic
-
Verified
A DESCRIPTION OF THE PROBLEM :
For calling server which is responding with non 100 statusCode.
On an httpUrlConnection instance created for upload. If the getOutputStream() method fails with expect100 error, and then if any other method is called on that instance (ex getHeaderField(), or getHeaderFields()). They will internally call getOuputStream() which invokes writeRequests(), which make the actual server call.
If these methods are called n times, it will try to invoke (n+1) server calls.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
//Lets assume that server return non-100 statusCode everytime server call is invoked.
HttpUrlConnection conn = url.openConnection();
try {
conn.getOutputStream();
} catch(Exception e) {}
for(int i=0;i<n;i++) {conn.getHeaderField("headerName");}
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
There should be only one server call.
ACTUAL -
There would be (n+1) server calls.
CUSTOMER SUBMITTED WORKAROUND :
There is a variable `rememberedException` used in getInputStream0() which gets set when disconnectInternal() is called from getInputStream0(). If something like this variable can be there in getOutputStream0() which knows that the connection failed due to 100-continue error (ProtocolException here, which invokes disconnectInternal()) and returns from there.
FREQUENCY : always
For calling server which is responding with non 100 statusCode.
On an httpUrlConnection instance created for upload. If the getOutputStream() method fails with expect100 error, and then if any other method is called on that instance (ex getHeaderField(), or getHeaderFields()). They will internally call getOuputStream() which invokes writeRequests(), which make the actual server call.
If these methods are called n times, it will try to invoke (n+1) server calls.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
//Lets assume that server return non-100 statusCode everytime server call is invoked.
HttpUrlConnection conn = url.openConnection();
try {
conn.getOutputStream();
} catch(Exception e) {}
for(int i=0;i<n;i++) {conn.getHeaderField("headerName");}
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
There should be only one server call.
ACTUAL -
There would be (n+1) server calls.
CUSTOMER SUBMITTED WORKAROUND :
There is a variable `rememberedException` used in getInputStream0() which gets set when disconnectInternal() is called from getInputStream0(). If something like this variable can be there in getOutputStream0() which knows that the connection failed due to 100-continue error (ProtocolException here, which invokes disconnectInternal()) and returns from there.
FREQUENCY : always
- duplicates
-
JDK-8315461 When Expect-100 Continue support is enabled, failure reason is not remembered
- Closed