This is an automated email from the ASF dual-hosted git repository.

lgoldstein pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mina-sshd.git

commit edf217c0b22bd2fc63e813ed31425933b5d35ea4
Author: Lyor Goldstein <[email protected]>
AuthorDate: Tue Apr 16 11:03:45 2019 +0300

    [SSHD-902] Rename 'handleEof' to 'shutdownOutputStream' for IoSession
---
 CHANGES.md                                                  |  2 ++
 .../org/apache/sshd/common/forward/TcpipClientChannel.java  |  2 +-
 .../src/main/java/org/apache/sshd/common/io/IoSession.java  |  2 +-
 .../java/org/apache/sshd/common/io/nio2/Nio2Session.java    |  5 ++++-
 .../sshd/common/session/helpers/AbstractSessionTest.java    |  2 +-
 .../java/org/apache/sshd/common/io/mina/MinaSession.java    | 13 ++++++++-----
 .../src/main/java/org/apache/sshd/netty/NettyIoSession.java | 13 ++++++++-----
 7 files changed, 25 insertions(+), 14 deletions(-)

diff --git a/CHANGES.md b/CHANGES.md
index 2011c87..fe3fa8b 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -118,6 +118,8 @@ if opening a shell or command channel.
 * [SSHD-901](https://issues.apache.org/jira/browse/SSHD-901) - Added 
capability to request a reply for the `keepalive@...` heartbeat request
 in order to avoid client-side session timeout due to no traffic from server.
 
+* [SSHD-902](https://issues.apache.org/jira/browse/SSHD-902) - Shutdown output 
when receiving `SSH_MSG_CHANNEL_EOF` message via port forwarding channel.
+
 * [SSHD-903](https://issues.apache.org/jira/browse/SSHD-903) - Fixed the SFTP 
version negotiation behavior in case client proposed version is higher than 
server supported one.
 
 * [SSHD-904](https://issues.apache.org/jira/browse/SSHD-904) - Add option to 
enable/disable 'fsync' on modified file contents via SFTP (default=enabled).
diff --git 
a/sshd-core/src/main/java/org/apache/sshd/common/forward/TcpipClientChannel.java
 
b/sshd-core/src/main/java/org/apache/sshd/common/forward/TcpipClientChannel.java
index cccd2a8..b83393b 100644
--- 
a/sshd-core/src/main/java/org/apache/sshd/common/forward/TcpipClientChannel.java
+++ 
b/sshd-core/src/main/java/org/apache/sshd/common/forward/TcpipClientChannel.java
@@ -220,6 +220,6 @@ public class TcpipClientChannel extends 
AbstractClientChannel implements Forward
     @Override
     public void handleEof() throws IOException {
         super.handleEof();
-        serverSession.handleEof();
+        serverSession.shudownOutputStream();
     }
 }
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/io/IoSession.java 
b/sshd-core/src/main/java/org/apache/sshd/common/io/IoSession.java
index 78eea71..6046541 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/io/IoSession.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/io/IoSession.java
@@ -89,5 +89,5 @@ public interface IoSession extends 
ConnectionEndpointsIndicator, PacketWriter, C
     /**
      * Handle received EOF.
      */
-    void handleEof() throws IOException;
+    void shudownOutputStream() throws IOException;
 }
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 adf2af2..a0e1a68 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
@@ -300,9 +300,12 @@ public class Nio2Session extends AbstractCloseable 
implements IoSession {
     }
 
     @Override
-    public void handleEof() throws IOException {
+    public void shudownOutputStream() throws IOException {
         AsynchronousSocketChannel socket = getSocket();
         if (socket.isOpen()) {
+            if (log.isDebugEnabled()) {
+                log.debug("shudownOutputStream({})", this);
+            }
             socket.shutdownOutput();
         }
     }
diff --git 
a/sshd-core/src/test/java/org/apache/sshd/common/session/helpers/AbstractSessionTest.java
 
b/sshd-core/src/test/java/org/apache/sshd/common/session/helpers/AbstractSessionTest.java
index 776aea8..c3351a8 100644
--- 
a/sshd-core/src/test/java/org/apache/sshd/common/session/helpers/AbstractSessionTest.java
+++ 
b/sshd-core/src/test/java/org/apache/sshd/common/session/helpers/AbstractSessionTest.java
@@ -412,7 +412,7 @@ public class AbstractSessionTest extends BaseTestSupport {
         }
 
         @Override
-        public void handleEof() {
+        public void shudownOutputStream() {
           // do nothing
         }
     }
diff --git 
a/sshd-mina/src/main/java/org/apache/sshd/common/io/mina/MinaSession.java 
b/sshd-mina/src/main/java/org/apache/sshd/common/io/mina/MinaSession.java
index c32f677..0751747 100644
--- a/sshd-mina/src/main/java/org/apache/sshd/common/io/mina/MinaSession.java
+++ b/sshd-mina/src/main/java/org/apache/sshd/common/io/mina/MinaSession.java
@@ -209,11 +209,11 @@ public class MinaSession extends AbstractInnerCloseable 
implements IoSession {
     }
 
     @Override   // see SSHD-902
-    public void handleEof() throws IOException {
+    public void shudownOutputStream() throws IOException {
         boolean debugEnabled = log.isDebugEnabled();
         if (!(session instanceof NioSession)) {
             if (debugEnabled) {
-                log.debug("handleEof({}) not a NioSession: {}",
+                log.debug("shudownOutputStream({}) not a NioSession: {}",
                     session, (session == null) ? null : 
session.getClass().getSimpleName());
             }
             return;
@@ -221,7 +221,7 @@ public class MinaSession extends AbstractInnerCloseable 
implements IoSession {
 
         if (NIO_SESSION_CHANNEL_FIELD == null) {
             if (debugEnabled) {
-                log.debug("handleEof({}) missing channel field",
+                log.debug("shudownOutputStream({}) missing channel field",
                     session, (session == null) ? null : 
session.getClass().getSimpleName());
             }
             return;
@@ -232,14 +232,14 @@ public class MinaSession extends AbstractInnerCloseable 
implements IoSession {
             channel = (Channel) NIO_SESSION_CHANNEL_FIELD.get(session);
         } catch (Exception t) {
             Throwable e = GenericUtils.peelException(t);
-            log.warn("handleEof({}) failed ({}) to retrieve embedded channel: 
{}",
+            log.warn("shudownOutputStream({}) failed ({}) to retrieve embedded 
channel: {}",
                 session, e.getClass().getSimpleName(), e.getMessage());
             return;
         }
 
         if (!(channel instanceof SocketChannel)) {
             if (debugEnabled) {
-                log.debug("handleEof({}) not a SocketChannel: {}",
+                log.debug("shudownOutputStream({}) not a SocketChannel: {}",
                     session, (channel == null) ? null : 
channel.getClass().getSimpleName());
             }
             return;
@@ -247,6 +247,9 @@ public class MinaSession extends AbstractInnerCloseable 
implements IoSession {
 
         Socket socket = ((SocketChannel) channel).socket();
         if (socket.isConnected() && (!socket.isClosed())) {
+            if (debugEnabled) {
+                log.debug("shudownOutputStream({})", session);
+            }
             socket.shutdownOutput();
         }
     }
diff --git a/sshd-netty/src/main/java/org/apache/sshd/netty/NettyIoSession.java 
b/sshd-netty/src/main/java/org/apache/sshd/netty/NettyIoSession.java
index 0a3365e..521de9f 100644
--- a/sshd-netty/src/main/java/org/apache/sshd/netty/NettyIoSession.java
+++ b/sshd-netty/src/main/java/org/apache/sshd/netty/NettyIoSession.java
@@ -166,12 +166,12 @@ public class NettyIoSession extends AbstractCloseable 
implements IoSession {
     }
 
     @Override   // see SSHD-902
-    public void handleEof() throws IOException {
+    public void shudownOutputStream() throws IOException {
         Channel ch = context.channel();
         boolean debugEnabled = log.isDebugEnabled();
         if (!(ch instanceof AbstractNioChannel)) {
             if (debugEnabled) {
-                log.debug("handleEof({}) channel is not AbstractNioChannel: 
{}",
+                log.debug("shudownOutputStream({}) channel is not 
AbstractNioChannel: {}",
                     this, (ch == null) ? null : ch.getClass().getSimpleName());
             }
             return;
@@ -179,7 +179,7 @@ public class NettyIoSession extends AbstractCloseable 
implements IoSession {
 
         if (NIO_JAVA_CHANNEL_METHOD == null) {
             if (debugEnabled) {
-                log.debug("handleEof({}) missing channel access method", this);
+                log.debug("shudownOutputStream({}) missing channel access 
method", this);
             }
             return;
         }
@@ -189,14 +189,14 @@ public class NettyIoSession extends AbstractCloseable 
implements IoSession {
             channel = (SelectableChannel) NIO_JAVA_CHANNEL_METHOD.invoke(ch, 
GenericUtils.EMPTY_OBJECT_ARRAY);
         } catch (Exception t) {
             Throwable e = GenericUtils.peelException(t);
-            log.warn("handleEof({}) failed ({}) to retrieve embedded channel: 
{}",
+            log.warn("shudownOutputStream({}) failed ({}) to retrieve embedded 
channel: {}",
                 this, e.getClass().getSimpleName(), e.getMessage());
             return;
         }
 
         if (!(channel instanceof SocketChannel)) {
             if (debugEnabled) {
-                log.debug("handleEof({}) not a SocketChannel: {}",
+                log.debug("shudownOutputStream({}) not a SocketChannel: {}",
                     this, (channel == null) ? null : 
channel.getClass().getSimpleName());
             }
             return;
@@ -204,6 +204,9 @@ public class NettyIoSession extends AbstractCloseable 
implements IoSession {
 
         Socket socket = ((SocketChannel) channel).socket();
         if (socket.isConnected() && (!socket.isClosed())) {
+            if (debugEnabled) {
+                log.debug("shudownOutputStream({})", this);
+            }
             socket.shutdownOutput();
         }
     }

Reply via email to