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 2017/10/04 13:16:34 UTC

mina-sshd git commit: Use a more descriptive exception when canceling pending asynchronous write requests due to immediate session close

Repository: mina-sshd
Updated Branches:
  refs/heads/master f5acda557 -> 654bb269f


Use a more descriptive exception when canceling pending asynchronous write requests due to immediate session close


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

Branch: refs/heads/master
Commit: 654bb269f4440b0c0ecb62a5e5be536d520a02e9
Parents: f5acda5
Author: Lyor Goldstein <ly...@gmail.com>
Authored: Wed Oct 4 16:17:42 2017 +0300
Committer: Lyor Goldstein <ly...@gmail.com>
Committed: Wed Oct 4 16:17:42 2017 +0300

----------------------------------------------------------------------
 .../main/java/org/apache/sshd/common/io/nio2/Nio2Session.java | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/654bb269/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 da07efd..0401224 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
@@ -19,6 +19,7 @@
 package org.apache.sshd.common.io.nio2;
 
 import java.io.IOException;
+import java.io.WriteAbortedException;
 import java.net.SocketAddress;
 import java.nio.ByteBuffer;
 import java.nio.channels.AsynchronousSocketChannel;
@@ -193,9 +194,13 @@ public class Nio2Session extends AbstractCloseable implements IoSession {
     @Override
     protected void doCloseImmediately() {
         for (;;) {
+            // Cancel pending requests informing them of the cancellation
             Nio2DefaultIoWriteFuture future = writes.poll();
             if (future != null) {
-                future.setException(new ClosedChannelException());
+                Throwable error = future.getException();
+                if (error == null) {
+                    future.setException(new WriteAbortedException("Write request aborted due to immediate session close", null));
+                }
             } else {
                 break;
             }