You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mina.apache.org by lg...@apache.org on 2016/02/09 16:50:54 UTC

mina-sshd git commit: Added more information to logged information for write cycle completion

Repository: mina-sshd
Updated Branches:
  refs/heads/master c44b07b55 -> e79f40903


Added more information to logged information for write cycle completion


Project: http://git-wip-us.apache.org/repos/asf/mina-sshd/repo
Commit: http://git-wip-us.apache.org/repos/asf/mina-sshd/commit/e79f4090
Tree: http://git-wip-us.apache.org/repos/asf/mina-sshd/tree/e79f4090
Diff: http://git-wip-us.apache.org/repos/asf/mina-sshd/diff/e79f4090

Branch: refs/heads/master
Commit: e79f409039a50582ac992e537f923aec38d38a39
Parents: c44b07b
Author: Lyor Goldstein <lg...@vmware.com>
Authored: Tue Feb 9 17:50:18 2016 +0200
Committer: Lyor Goldstein <lg...@vmware.com>
Committed: Tue Feb 9 17:50:18 2016 +0200

----------------------------------------------------------------------
 .../apache/sshd/common/io/nio2/Nio2Session.java | 21 ++++++++++++++------
 1 file changed, 15 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/e79f4090/sshd-core/src/main/java/org/apache/sshd/common/io/nio2/Nio2Session.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/io/nio2/Nio2Session.java b/sshd-core/src/main/java/org/apache/sshd/common/io/nio2/Nio2Session.java
index 13426c6..ba68609 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/io/nio2/Nio2Session.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/io/nio2/Nio2Session.java
@@ -342,35 +342,36 @@ public class Nio2Session extends AbstractCloseable implements IoSession {
 
     protected Nio2CompletionHandler<Integer, Object> createWriteCycleCompletionHandler(
             final Nio2DefaultIoWriteFuture future, final AsynchronousSocketChannel socket, final ByteBuffer buffer) {
+        final int writeLen = buffer.remaining();
         return new Nio2CompletionHandler<Integer, Object>() {
             @Override
             protected void onCompleted(Integer result, Object attachment) {
-                handleCompletedWriteCycle(future, socket, buffer, this, result, attachment);
+                handleCompletedWriteCycle(future, socket, buffer, writeLen, this, result, attachment);
             }
 
             @Override
             protected void onFailed(Throwable exc, Object attachment) {
-                handleWriteCycleFailure(future, socket, buffer, exc, attachment);
+                handleWriteCycleFailure(future, socket, buffer, writeLen, exc, attachment);
             }
         };
     }
 
     protected void handleCompletedWriteCycle(
-            Nio2DefaultIoWriteFuture future, AsynchronousSocketChannel socket, ByteBuffer buffer,
+            Nio2DefaultIoWriteFuture future, AsynchronousSocketChannel socket, ByteBuffer buffer, int writeLen,
             Nio2CompletionHandler<Integer, Object> completionHandler, Integer result, Object attachment) {
         if (buffer.hasRemaining()) {
             try {
                 socket.write(buffer, null, completionHandler);
             } catch (Throwable t) {
                 if (log.isDebugEnabled()) {
-                    log.debug("handleCompletedWriteCycle(" + this + ") Exception caught while writing", t);
+                    log.debug("handleCompletedWriteCycle(" + this + ") Exception caught while writing " + writeLen + " bytes", t);
                 }
                 future.setWritten();
                 finishWrite(future);
             }
         } else {
             if (log.isDebugEnabled()) {
-                log.debug("handleCompletedWriteCycle({}) finished writing", this);
+                log.debug("handleCompletedWriteCycle({}) finished writing len={}", this, writeLen);
             }
             future.setWritten();
             finishWrite(future);
@@ -378,7 +379,15 @@ public class Nio2Session extends AbstractCloseable implements IoSession {
     }
 
     protected void handleWriteCycleFailure(
-            Nio2DefaultIoWriteFuture future, AsynchronousSocketChannel socket, ByteBuffer buffer, Throwable exc, Object attachment) {
+            Nio2DefaultIoWriteFuture future, AsynchronousSocketChannel socket,
+            ByteBuffer buffer, int writeLen, Throwable exc, Object attachment) {
+        if (log.isDebugEnabled()) {
+            log.debug("handleWriteCycleFailure({}) failed ({}) to write {} bytes: {}",
+                      this, exc.getClass().getSimpleName(), writeLen, exc.getMessage());
+        }
+        if (log.isTraceEnabled()) {
+            log.trace("handleWriteCycleFailure(" + this + ") len=" + writeLen + " failure details", exc);
+        }
         future.setException(exc);
         exceptionCaught(exc);
         finishWrite(future);