changeset 57830:26dbc9b2c8dc

8236596: HttpClient leaves HTTP/2 sockets in CLOSE_WAIT, when using proxy tunnel Summary: Changes Http2ClientImpl::stop to close the TCP connection after sending out the GOAWAY frame. Reviewed-by: chegar
author dfuchs
date Fri, 24 Jan 2020 17:57:41 +0000
parents 559fcd53e782
children 9af9aac9996a
files src/java.net.http/share/classes/jdk/internal/net/http/Http2ClientImpl.java
diffstat 1 files changed, 5 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/java.net.http/share/classes/jdk/internal/net/http/Http2ClientImpl.java	Fri Jan 24 16:16:39 2020 +0000
+++ b/src/java.net.http/share/classes/jdk/internal/net/http/Http2ClientImpl.java	Fri Jan 24 17:57:41 2020 +0000
@@ -25,6 +25,7 @@
 
 package jdk.internal.net.http;
 
+import java.io.EOFException;
 import java.io.IOException;
 import java.io.UncheckedIOException;
 import java.net.ConnectException;
@@ -186,14 +187,18 @@
         }
     }
 
+    private EOFException STOPPED;
     void stop() {
         if (debug.on()) debug.log("stopping");
+        STOPPED = new EOFException("HTTP/2 client stopped");
+        STOPPED.setStackTrace(new StackTraceElement[0]);
         connections.values().forEach(this::close);
         connections.clear();
     }
 
     private void close(Http2Connection h2c) {
         try { h2c.close(); } catch (Throwable t) {}
+        try { h2c.shutdown(STOPPED); } catch (Throwable t) {}
     }
 
     HttpClientImpl client() {