http-client-branch: Improve channel traces http-client-branch
authordfuchs
Mon, 18 Jun 2018 09:57:09 +0100
branchhttp-client-branch
changeset 56770 f1626bc0a010
parent 56768 d6b08065edf5
child 56771 73a6534bce94
http-client-branch: Improve channel traces
src/java.net.http/share/classes/jdk/internal/net/http/SocketTube.java
--- a/src/java.net.http/share/classes/jdk/internal/net/http/SocketTube.java	Fri Jun 15 17:32:00 2018 +0100
+++ b/src/java.net.http/share/classes/jdk/internal/net/http/SocketTube.java	Mon Jun 18 09:57:09 2018 +0100
@@ -419,7 +419,7 @@
         void signalError(Throwable error) {
             debug.log(() -> "write error: " + error);
             if (Log.channel()) {
-                Log.logChannel("Failed to write on channel ({0}: {1})",
+                Log.logChannel("Failed to write to channel ({0}: {1})",
                         channelDescr(), error);
             }
             completed = true;
@@ -721,6 +721,10 @@
             @Override
             public final void cancel() {
                 pauseReadEvent();
+                if (Log.channel()) {
+                    Log.logChannel("Read subscription cancelled for channel {0}",
+                            channelDescr());
+                }
                 readScheduler.stop();
             }
 
@@ -745,6 +749,10 @@
                     return;
                 }
                 if (debug.on()) debug.log("got read error: " + error);
+                if (Log.channel()) {
+                    Log.logChannel("Read error signalled on channel {0}: {1}",
+                            channelDescr(), error);
+                }
                 readScheduler.runOrSchedule();
             }
 
@@ -791,6 +799,10 @@
                             if (debug.on())
                                 debug.log("Sending error " + error
                                           + " to subscriber " + subscriber);
+                            if (Log.channel()) {
+                                Log.logChannel("Raising error with subscriber for {0}: {1}",
+                                        channelDescr(), error);
+                            }
                             current.errorRef.compareAndSet(null, error);
                             current.signalCompletion();
                             readScheduler.stop();
@@ -808,7 +820,7 @@
                                     if (!completed) {
                                         if (debug.on()) debug.log("got read EOF");
                                         if (Log.channel()) {
-                                            Log.logChannel("EOF reached from channel: {0}",
+                                            Log.logChannel("EOF read from channel: {0}",
                                                         channelDescr());
                                         }
                                         completed = true;
@@ -872,6 +884,12 @@
                     if (debug.on()) debug.log("Unexpected exception in read loop", t);
                     signalError(t);
                 } finally {
+                    if (readScheduler.isStopped()) {
+                        if (debug.on()) debug.log("Read scheduler stopped");
+                        if (Log.channel()) {
+                            Log.logChannel("Stopped reading from channel {0}", channelDescr());
+                        }
+                    }
                     handlePending();
                 }
             }