File tree Expand file tree Collapse file tree 2 files changed +1
-37
lines changed
google-http-client-apache-v2/src/test/java/com/google/api/client/http/apache/v2
google-http-client/src/main/java/com/google/api/client/http Expand file tree Collapse file tree 2 files changed +1
-37
lines changed Original file line number Diff line number Diff line change @@ -321,38 +321,4 @@ public void handle(HttpExchange httpExchange) throws IOException {
321
321
private boolean isWindows () {
322
322
return System .getProperty ("os.name" ).startsWith ("Windows" );
323
323
}
324
-
325
- @ Test (timeout = 10_000L )
326
- public void testDisconnectShouldNotWaitToReadResponse () throws IOException {
327
- // This handler waits for 100s before returning writing content. The test should
328
- // timeout if disconnect waits for the response before closing the connection.
329
- final HttpHandler handler =
330
- new HttpHandler () {
331
- @ Override
332
- public void handle (HttpExchange httpExchange ) throws IOException {
333
- byte [] response = httpExchange .getRequestURI ().toString ().getBytes ();
334
- httpExchange .sendResponseHeaders (200 , response .length );
335
-
336
- // Sleep for longer than the test timeout
337
- try {
338
- Thread .sleep (100_000 );
339
- } catch (InterruptedException e ) {
340
- throw new IOException ("interrupted" , e );
341
- }
342
- try (OutputStream out = httpExchange .getResponseBody ()) {
343
- out .write (response );
344
- }
345
- }
346
- };
347
-
348
- try (FakeServer server = new FakeServer (handler )) {
349
- HttpTransport transport = new ApacheHttpTransport ();
350
- GenericUrl testUrl = new GenericUrl ("http://localhost/foo//bar" );
351
- testUrl .setPort (server .getPort ());
352
- com .google .api .client .http .HttpResponse response =
353
- transport .createRequestFactory ().buildGetRequest (testUrl ).execute ();
354
- // disconnect should not wait to read the entire content
355
- response .disconnect ();
356
- }
357
- }
358
324
}
Original file line number Diff line number Diff line change @@ -442,10 +442,8 @@ public void ignore() throws IOException {
442
442
* @since 1.4
443
443
*/
444
444
public void disconnect () throws IOException {
445
- // Close the connection before trying to close the InputStream content. If you are trying to
446
- // disconnect, we shouldn't need to read any further content.
447
- response .disconnect ();
448
445
ignore ();
446
+ response .disconnect ();
449
447
}
450
448
451
449
/**
You can’t perform that action at this time.
0 commit comments