Closed
@BenWhitehead

Description

HttpURLConnection will silently retry DELETE requests. This behavior is similar to other existing JDK bugs (JDK-6382788, JDK-6427251). google-http-java-client already contains a workaround (NetHttpRequest.java#L108-L112) for those requests which have a body, but does not account for DELETE with an empty body.

For Google Cloud Storage, while developing a conformance test suite for retry handling I ran into this bug and will submit a fix.

Environment details

  1. NetHttp
  2. OS type and version: Debian Linux
  3. Java version:
    openjdk version "1.8.0_292"
    OpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_292-b10)
    OpenJDK 64-Bit Server VM (AdoptOpenJDK)(build 25.292-b10, mixed mode)
    
  4. google-http-client version(s): 1.40.0 and older

Steps to reproduce

  1. start a "server" which closes the connection without sending a response
    socat tcp4-listen:8080,fork,reuseaddr system:"sleep 1"\!\!stdout
    
  2. run the following code and observe two requests in the server output
    URL url = new URL("http://localhost:8080");
    HttpURLConnection conn = (HttpURLConnection) url.openConnection();
    conn.setRequestMethod("DELETE");
    
    conn.getResponseCode();
    

Code example

See rerpo step 3

Stack trace

No relevant stack trace

External references such as API reference guides