http-client-branch: add more diagnosis to detachChannel http-client-branch
authordfuchs
Wed, 14 Mar 2018 14:32:07 +0000
branchhttp-client-branch
changeset 56305 9027d1747dd0
parent 56304 065641767a75
child 56306 88c1f551d45e
http-client-branch: add more diagnosis to detachChannel
src/java.net.http/share/classes/jdk/internal/net/http/HttpClientImpl.java
src/java.net.http/share/classes/jdk/internal/net/http/SocketTube.java
--- a/src/java.net.http/share/classes/jdk/internal/net/http/HttpClientImpl.java	Wed Mar 14 13:35:33 2018 +0000
+++ b/src/java.net.http/share/classes/jdk/internal/net/http/HttpClientImpl.java	Wed Mar 14 14:32:07 2018 +0000
@@ -521,7 +521,9 @@
         ConnectionPool pool;
 
         SelectorManager(HttpClientImpl ref) throws IOException {
-            super(null, null, "HttpClient-" + ref.id + "-SelectorManager", 0, false);
+            super(null, null,
+                  "HttpClient-" + ref.id + "-SelectorManager",
+                  0, false);
             owner = ref;
             debug = ref.debug;
             debugtimeout = ref.debugtimeout;
@@ -533,6 +535,7 @@
 
         void detach(SelectableChannel channel, AsyncEvent... events) {
             if (Thread.currentThread() == this) {
+                debug.log(Level.DEBUG, "detaching channel");
                 SelectionKey key = channel.keyFor(selector);
                 if (key != null) {
                     boolean removed = false;
@@ -552,8 +555,10 @@
                     }
                 }
                 registrations.removeAll(Arrays.asList(events));
+                debug.log(Level.DEBUG, "channel detached");
             } else {
                 synchronized (this) {
+                    debug.log(Level.DEBUG, "scheduling event to detach channel");
                     deregistrations.add(new AsyncTriggerEvent(
                             (x) -> debug.log(Level.DEBUG,
                                     "Unexpected exception raised while detaching channel", x),
--- a/src/java.net.http/share/classes/jdk/internal/net/http/SocketTube.java	Wed Mar 14 13:35:33 2018 +0000
+++ b/src/java.net.http/share/classes/jdk/internal/net/http/SocketTube.java	Wed Mar 14 14:32:07 2018 +0000
@@ -166,7 +166,9 @@
 
     void detach() {
         if (detached.compareAndSet(false, true)) {
+            debug.log(Level.DEBUG, "detaching tube");
             readPublisher.subscriptionImpl.readScheduler.stop();
+            debug.log(Level.DEBUG, "scheduler stopped");
             SocketFlowEvent[] events = {
                     readPublisher.subscriptionImpl.readEvent,
                     writeSubscriber.writeEvent
@@ -174,6 +176,7 @@
             for (SocketFlowEvent event : events) {
                 event.pause();
             }
+            debug.log(Level.DEBUG, "asking HttpClientImpl to detach channel");
             client.detachChannel(channel, events);
         }
     }