United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-6382788 URLConnection is silently retrying POST request
JDK-6382788 : URLConnection is silently retrying POST request

Details
Type:
Bug
Submit Date:
2006-02-08
Status:
Resolved
Updated Date:
2011-02-16
Project Name:
JDK
Resolved Date:
2006-07-01
Component:
core-libs
OS:
solaris_9,linux,windows_xp
Sub-Component:
java.net
CPU:
x86,sparc
Priority:
P2
Resolution:
Fixed
Affected Versions:
5.0,5.0u6
Fixed Versions:

Related Reports
Backport:
Backport:
Duplicate:
Duplicate:

Sub Tasks

Description
Client send a synchronous request. Server sleep for 10 minutes.
When this is the the first request that is sent between the client and the server, the client request is not retried. The client waits the expected amount of time.

If this is a request that comes after the first one, after EXACTLY 5 minutes, the request is retried.

It is not retried in the JAX-WS stack BUT at the HTTP transport level.
The retries is located in sun.net.www.http.HTTPClient.parseHTTPHeader(). 
After 5 minutes, the socket.read returns with a size == 0. Then the request is retried ONLY once.

I am wandering if this is the http stack or JAX-WS usage of it that is wrong.

I attached you a client, a server and a WSDL that show the problem EVERY TIME (at least on solaris).
I also attached a modified HTTPClient in order to trace what is going on.

In the JMX Connector, we are polling for Notifications. The Polling request can be waiting , on the server side, a very long time. We will ran into this issue.

                                    

Comments
EVALUATION

HttpURLConnection is behaving in accordance with RFC 2616 (HTTP/1.1) section 8.1.4 "Practical Considerations"
                                     
2006-04-04
EVALUATION

re-opening. The non-idempotent method, POST, should not be retried. It currently is.
                                     
2006-04-04
EVALUATION

Non-idempotent http POST requests are being automatically resent to the server if the server does not respond with a valid http response or an IOException occurs. This is incorrect according to the rfc. Only idempotent requests are supposed to be automatically resent.
 
As this has been the behavior of Sun's http client forever, some users may be relying on this behavior without even knowing it. So the solution is to allow this behavior to be configured through a system property, sun.net.http.retryPost.
 
sun.net.http.retryPost determines if the an unsuccessful http POST request will be automatically resent to the server. Unsuccessful in this case means the server did not send a valid http response or an IOException occurred. The default value is true to maintain backward compatibility.
 
This is a Sun implementation specific property that is only related to Sun's http protocol handler.
                                     
2006-06-20



Hardware and Software, Engineered to Work Together