rlalfo / google-http-java-client

Automatically exported from code.google.com/p/google-http-java-client
0 stars 0 forks source link

PUT requests with a null body can hang and timeout #256

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Version of google-http-java-client (e.g. 1.17.0-rc)?

1.17.0-rc (I expect it is also present in older versions too)

Java environment (e.g. Java 6, Android 2.3, App Engine)?

Java 6

Describe the problem.

Running the main method below (against a service that supports PUT) will hang 
when trying to invoke getInput() on the underlying java.net.HttpURLConnection - 
line 379 in java 1.6.0_45.

public static void main(String[] args) throws IOException {
  new NetHttpTransport()
      .createRequestFactory()
      .buildPutRequest(
          new GenericUrl("http://example.com"), null)
      .execute();
}

I don't know if this is specific to the server being called or if it's generic 
to all PUT requests (I couldn't find a public service that I could easily test 
it against). I would have to assume that if at least one server hangs the 
response connection awaiting the close of the request then there will be others.

This behaviour also happens when using the underlying java net URL too, but it 
can be fixed there by adding the line connection.getOutputStream().close().

How would you expect it to be fixed?

It would be nice if the client libraries would at least document that this may 
happen or even better error or default a PUT request to use an EmptyContent 
instead of not requesting the content at all.

Original issue reported on code.google.com by matt.nat...@gmail.com on 27 Jan 2014 at 5:10

GoogleCodeExporter commented 9 years ago
I guess this could be the same issue as Issue 220

Original comment by matt.nat...@gmail.com on 27 Jan 2014 at 5:26