diff --git a/google-http-client-apache-v2/src/test/java/com/google/api/client/http/apache/v2/ApacheHttpTransportTest.java b/google-http-client-apache-v2/src/test/java/com/google/api/client/http/apache/v2/ApacheHttpTransportTest.java index f6800ff47..be6f983c6 100644 --- a/google-http-client-apache-v2/src/test/java/com/google/api/client/http/apache/v2/ApacheHttpTransportTest.java +++ b/google-http-client-apache-v2/src/test/java/com/google/api/client/http/apache/v2/ApacheHttpTransportTest.java @@ -321,38 +321,4 @@ public void handle(HttpExchange httpExchange) throws IOException { private boolean isWindows() { return System.getProperty("os.name").startsWith("Windows"); } - - @Test(timeout = 10_000L) - public void testDisconnectShouldNotWaitToReadResponse() throws IOException { - // This handler waits for 100s before returning writing content. The test should - // timeout if disconnect waits for the response before closing the connection. - final HttpHandler handler = - new HttpHandler() { - @Override - public void handle(HttpExchange httpExchange) throws IOException { - byte[] response = httpExchange.getRequestURI().toString().getBytes(); - httpExchange.sendResponseHeaders(200, response.length); - - // Sleep for longer than the test timeout - try { - Thread.sleep(100_000); - } catch (InterruptedException e) { - throw new IOException("interrupted", e); - } - try (OutputStream out = httpExchange.getResponseBody()) { - out.write(response); - } - } - }; - - try (FakeServer server = new FakeServer(handler)) { - HttpTransport transport = new ApacheHttpTransport(); - GenericUrl testUrl = new GenericUrl("http://localhost/foo//bar"); - testUrl.setPort(server.getPort()); - com.google.api.client.http.HttpResponse response = - transport.createRequestFactory().buildGetRequest(testUrl).execute(); - // disconnect should not wait to read the entire content - response.disconnect(); - } - } } diff --git a/google-http-client/src/main/java/com/google/api/client/http/HttpResponse.java b/google-http-client/src/main/java/com/google/api/client/http/HttpResponse.java index f7bf0b42c..e97943210 100644 --- a/google-http-client/src/main/java/com/google/api/client/http/HttpResponse.java +++ b/google-http-client/src/main/java/com/google/api/client/http/HttpResponse.java @@ -442,10 +442,8 @@ public void ignore() throws IOException { * @since 1.4 */ public void disconnect() throws IOException { - // Close the connection before trying to close the InputStream content. If you are trying to - // disconnect, we shouldn't need to read any further content. - response.disconnect(); ignore(); + response.disconnect(); } /**