Upgrade sshd to 2.6.0 64/94964/8
authorIaroslav <iaroslav.kholiavko@pantheon.tech>
Tue, 2 Feb 2021 14:31:46 +0000 (16:31 +0200)
committerRobert Varga <nite@hq.sk>
Sun, 21 Feb 2021 11:33:07 +0000 (11:33 +0000)
Upgrade sshd to version 2.6.0

JIRA: NETCONF-752
Change-Id: Iaf6fd1ab232458aeb58636590bc84d3d8d2036f6
Signed-off-by: Iaroslav <iaroslav.kholiavko@pantheon.tech>
15 files changed:
netconf/callhome-protocol/src/main/java/org/opendaylight/netconf/callhome/protocol/CallHomeSessionContext.java
netconf/callhome-protocol/src/main/java/org/opendaylight/netconf/callhome/protocol/NetconfCallHomeServer.java
netconf/callhome-protocol/src/test/java/org/opendaylight/netconf/callhome/protocol/CallHomeSessionContextTest.java
netconf/callhome-protocol/src/test/java/org/opendaylight/netconf/callhome/protocol/MinaSshNettyChannelTest.java
netconf/callhome-protocol/src/test/java/org/opendaylight/netconf/callhome/protocol/NetconfCallHomeServerTest.java
netconf/mdsal-netconf-ssh/src/main/java/org/opendaylight/netconf/ssh/SshProxyServer.java
netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/handler/ssh/client/AsyncSshHandler.java
netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/handler/ssh/client/AsyncSshHandlerWriter.java
netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/handler/ssh/client/NetconfSshClient.java
netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/handler/ssh/sshd1028/NetconfNio2Connector.java [deleted file]
netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/handler/ssh/sshd1028/NetconfNio2ServiceFactory.java [deleted file]
netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/handler/ssh/sshd1028/NetconfNio2ServiceFactoryFactory.java [deleted file]
netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/handler/ssh/sshd1028/NetconfNio2Session.java [deleted file]
netconf/netconf-netty-util/src/test/java/org/opendaylight/netconf/nettyutil/handler/ssh/client/AsyncSshHandlerTest.java
netconf/shaded-sshd-jar/pom.xml

index 68902d8da73f2af1684a7e6034ec5fb77bd8b687..bbdfabbc5f980caa61c3982c245a00bd5ab63fc8 100644 (file)
@@ -56,7 +56,7 @@ class CallHomeSessionContext implements CallHomeProtocolSessionContext {
         this.sshSession = requireNonNull(sshSession, "sshSession");
         this.sshSession.setAttribute(SESSION_KEY, this);
         this.remoteAddress = (InetSocketAddress) this.sshSession.getIoSession().getRemoteAddress();
-        this.serverKey = this.sshSession.getKex().getServerKey();
+        this.serverKey = this.sshSession.getServerKey();
     }
 
     static CallHomeSessionContext getFrom(final ClientSession sshSession) {
index 008d8f7c566b5637c002c18d3ade0859342a564c..eff2483fdb31295c19a9154b68b817b0af8cb90e 100644 (file)
@@ -116,7 +116,7 @@ public class NetconfCallHomeServer implements AutoCloseable, ServerKeyVerifier {
     @SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD",
             justification = "https://github.com/spotbugs/spotbugs/issues/811")
     private SshFutureListener<AuthFuture> newAuthSshFutureListener(final ClientSession session) {
-        final PublicKey serverKey = session.getKex().getServerKey();
+        final PublicKey serverKey = session.getServerKey();
 
         return new SshFutureListener<AuthFuture>() {
             @Override
index 469d7d4d4c67f33109c1ed341d1641d474d2a81f..58560706ca8fc86aeb22d24b6030fe387fac49a4 100644 (file)
@@ -31,11 +31,11 @@ import org.opendaylight.netconf.client.NetconfClientSessionListener;
 import org.opendaylight.netconf.client.NetconfClientSessionNegotiatorFactory;
 import org.opendaylight.netconf.shaded.sshd.client.channel.ChannelSubsystem;
 import org.opendaylight.netconf.shaded.sshd.client.channel.ClientChannel;
-import org.opendaylight.netconf.shaded.sshd.client.channel.ClientChannel.Streaming;
 import org.opendaylight.netconf.shaded.sshd.client.future.OpenFuture;
 import org.opendaylight.netconf.shaded.sshd.client.session.ClientSession;
 import org.opendaylight.netconf.shaded.sshd.client.session.ClientSessionImpl;
 import org.opendaylight.netconf.shaded.sshd.common.AttributeRepository.AttributeKey;
+import org.opendaylight.netconf.shaded.sshd.common.channel.StreamingChannel;
 import org.opendaylight.netconf.shaded.sshd.common.future.SshFutureListener;
 import org.opendaylight.netconf.shaded.sshd.common.io.IoInputStream;
 import org.opendaylight.netconf.shaded.sshd.common.io.IoOutputStream;
@@ -74,7 +74,7 @@ public class CallHomeSessionContextTest {
         Mockito.doReturn(kexMock).when(mockSession).getKex();
 
         PublicKey keyMock = Mockito.mock(PublicKey.class);
-        Mockito.doReturn(keyMock).when(kexMock).getServerKey();
+        Mockito.doReturn(keyMock).when(mockSession).getServerKey();
         IoReadFuture mockFuture = mock(IoReadFuture.class);
         IoInputStream mockIn = mock(IoInputStream.class);
         Mockito.doReturn(mockFuture).when(mockIn).read(any(Buffer.class));
@@ -126,7 +126,7 @@ public class CallHomeSessionContextTest {
         Mockito.doReturn(mockChannelSubsystem).when(mockSession).createSubsystemChannel(anyString());
 
         Mockito.doReturn(null).when(mockFuture).addListener(any(SshFutureListener.class));
-        doNothing().when(mockChannelSubsystem).setStreaming(any(Streaming.class));
+        doNothing().when(mockChannelSubsystem).setStreaming(any(StreamingChannel.Streaming.class));
         instance = realFactory.createIfNotExists(mockSession, mockAuth, address);
         // when
         instance.openNetconfChannel();
index 6eceed7c4ede6f6d88bc5b55124fc417e2b0f393..a7451eb54430404fe91c197e9b905288380216ec 100644 (file)
@@ -54,7 +54,7 @@ public class MinaSshNettyChannelTest {
         IoWriteFuture mockWrFuture = mock(IoWriteFuture.class);
         Mockito.doReturn(false).when(mockOut).isClosed();
         Mockito.doReturn(false).when(mockOut).isClosing();
-        Mockito.doReturn(mockWrFuture).when(mockOut).writePacket(any(Buffer.class));
+        Mockito.doReturn(mockWrFuture).when(mockOut).writeBuffer(any(Buffer.class));
         Mockito.doReturn(null).when(mockWrFuture).addListener(any());
 
         Mockito.doReturn(mockFuture).when(mockFuture).addListener(Mockito.any());
index a27ba05076d7382fe2237f1190fd2e6befd660ef..ca41cf1408d8420c65db99224ab017b7a1fe6c17 100644 (file)
@@ -40,7 +40,6 @@ import org.opendaylight.netconf.shaded.sshd.common.future.SshFutureListener;
 import org.opendaylight.netconf.shaded.sshd.common.io.IoAcceptor;
 import org.opendaylight.netconf.shaded.sshd.common.io.IoHandler;
 import org.opendaylight.netconf.shaded.sshd.common.io.IoServiceFactory;
-import org.opendaylight.netconf.shaded.sshd.common.kex.KeyExchange;
 import org.opendaylight.netconf.shaded.sshd.common.session.Session;
 import org.opendaylight.netconf.shaded.sshd.common.session.SessionListener;
 
@@ -115,10 +114,8 @@ public class NetconfCallHomeServerTest {
             doNothing().when(mockContext).openNetconfChannel();
             doReturn(mockContext).when(mockSession).getAttribute(any(Session.AttributeKey.class));
 
-            final KeyExchange kex = mock(KeyExchange.class);
-            doReturn(kex).when(mockSession).getKex();
             final PublicKey serverKey = mock(PublicKey.class);
-            doReturn(serverKey).when(kex).getServerKey();
+            doReturn(serverKey).when(mockSession).getServerKey();
 
             SessionListener listener = instance.createSessionListener();
             doReturn(mockAuthFuture).when(mockContext).authorize();
index 785a519ff5edae80bf016dc0fd72c969b44b1424..1630c1b6d647361faae1063fc86afd8d6af3286a 100644 (file)
@@ -35,6 +35,7 @@ import org.opendaylight.netconf.shaded.sshd.common.io.nio2.Nio2Connector;
 import org.opendaylight.netconf.shaded.sshd.common.io.nio2.Nio2ServiceFactoryFactory;
 import org.opendaylight.netconf.shaded.sshd.common.session.SessionHeartbeatController.HeartbeatType;
 import org.opendaylight.netconf.shaded.sshd.common.util.closeable.AbstractCloseable;
+import org.opendaylight.netconf.shaded.sshd.core.CoreModuleProperties;
 import org.opendaylight.netconf.shaded.sshd.server.SshServer;
 
 /**
@@ -91,7 +92,7 @@ public class SshProxyServer implements AutoCloseable {
         sshServer.setScheduledExecutorService(minaTimerExecutor);
 
         final int idleTimeout = sshProxyServerConfiguration.getIdleTimeout();
-        sshServer.getProperties().put(FactoryManager.IDLE_TIMEOUT, String.valueOf(idleTimeout));
+        sshServer.getProperties().put(CoreModuleProperties.IDLE_TIMEOUT.getName(), String.valueOf(idleTimeout));
         final String nioReadTimeout;
         if (idleTimeout > 0) {
             final long heartBeat = idleTimeout * 333333L;
@@ -100,8 +101,8 @@ public class SshProxyServer implements AutoCloseable {
         } else {
             nioReadTimeout = "0";
         }
-        sshServer.getProperties().put(FactoryManager.NIO2_READ_TIMEOUT, nioReadTimeout);
-        sshServer.getProperties().put(FactoryManager.AUTH_TIMEOUT, String.valueOf(idleTimeout));
+        sshServer.getProperties().put(CoreModuleProperties.NIO2_READ_TIMEOUT.getName(), nioReadTimeout);
+        sshServer.getProperties().put(CoreModuleProperties.AUTH_TIMEOUT.getName(), String.valueOf(idleTimeout));
 
         final RemoteNetconfCommand.NetconfCommandFactory netconfCommandFactory =
                 new RemoteNetconfCommand.NetconfCommandFactory(clientGroup,
index 6e89453ed423b5c0cc9e133a94d015c18de0801d..0eb635ef3d0866599909888ecdbe175eb2269162 100644 (file)
@@ -25,7 +25,7 @@ import org.opendaylight.netconf.shaded.sshd.client.channel.ClientChannel;
 import org.opendaylight.netconf.shaded.sshd.client.future.AuthFuture;
 import org.opendaylight.netconf.shaded.sshd.client.future.ConnectFuture;
 import org.opendaylight.netconf.shaded.sshd.client.session.ClientSession;
-import org.opendaylight.netconf.shaded.sshd.common.FactoryManager;
+import org.opendaylight.netconf.shaded.sshd.core.CoreModuleProperties;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -44,9 +44,9 @@ public class AsyncSshHandler extends ChannelOutboundHandlerAdapter {
     static {
         final NetconfSshClient c = new NetconfClientBuilder().build();
         // Disable default timeouts from mina sshd
-        c.getProperties().put(FactoryManager.AUTH_TIMEOUT, "0");
-        c.getProperties().put(FactoryManager.IDLE_TIMEOUT, "0");
-        c.getProperties().put(FactoryManager.NIO2_READ_TIMEOUT, "0");
+        c.getProperties().put(CoreModuleProperties.AUTH_TIMEOUT.getName(), "0");
+        c.getProperties().put(CoreModuleProperties.IDLE_TIMEOUT.getName(), "0");
+        c.getProperties().put(CoreModuleProperties.NIO2_READ_TIMEOUT.getName(), "0");
 
         // TODO make configurable, or somehow reuse netty threadpool
         c.setNioWorkers(SSH_DEFAULT_NIO_WORKERS);
index 5f06dd8e6f8a1ddee662f093f56a895907416457..e9ade8e474e3d22d9b78be9a07383428da2f10df 100644 (file)
@@ -93,7 +93,7 @@ public final class AsyncSshHandlerWriter implements AutoCloseable {
 
             isWriteExecuted = true;
 
-            asyncIn.writePacket(toBuffer(byteBufMsg)).addListener(future -> {
+            asyncIn.writeBuffer(toBuffer(byteBufMsg)).addListener(future -> {
                 // synchronized block due to deadlock that happens on ssh window resize
                 // writes and pending writes would lock the underlyinch channel session
                 // window resize write would try to write the message on an already locked channelSession,
index b4f318ebd25e2785baf5c388a1bd89ba0ad41ba0..d5d0d97aa955636191257b0ef4e8e792fbb1a9ae 100644 (file)
@@ -8,11 +8,8 @@
 package org.opendaylight.netconf.nettyutil.handler.ssh.client;
 
 import com.google.common.annotations.Beta;
-import org.opendaylight.netconf.nettyutil.handler.ssh.sshd1028.NetconfNio2ServiceFactoryFactory;
 import org.opendaylight.netconf.shaded.sshd.client.SshClient;
 import org.opendaylight.netconf.shaded.sshd.common.Factory;
-import org.opendaylight.netconf.shaded.sshd.common.io.IoConnector;
-
 
 /**
  * An extension to {@link SshClient} which uses {@link NetconfSessionFactory} to create sessions (leading towards
@@ -21,20 +18,9 @@ import org.opendaylight.netconf.shaded.sshd.common.io.IoConnector;
 @Beta
 public class NetconfSshClient extends SshClient {
     public static final Factory<SshClient> DEFAULT_NETCONF_SSH_CLIENT_FACTORY = NetconfSshClient::new;
-    private final NetconfNio2ServiceFactoryFactory nio2ServiceFactoryFactory;
-
-    public NetconfSshClient() {
-        this.nio2ServiceFactoryFactory = new NetconfNio2ServiceFactoryFactory();
-    }
 
     @Override
     protected NetconfSessionFactory createSessionFactory() {
         return new NetconfSessionFactory(this);
     }
-
-    @Override
-    protected IoConnector createConnector() {
-        setIoServiceFactoryFactory(nio2ServiceFactoryFactory);
-        return getIoServiceFactory().createConnector(getSessionFactory());
-    }
 }
diff --git a/netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/handler/ssh/sshd1028/NetconfNio2Connector.java b/netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/handler/ssh/sshd1028/NetconfNio2Connector.java
deleted file mode 100644 (file)
index c565ac2..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright (c) 2020 PANTHEON.tech, s.r.o. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.netconf.nettyutil.handler.ssh.sshd1028;
-
-import java.nio.channels.AsynchronousChannelGroup;
-import java.nio.channels.AsynchronousSocketChannel;
-import org.opendaylight.netconf.shaded.sshd.common.FactoryManager;
-import org.opendaylight.netconf.shaded.sshd.common.io.IoHandler;
-import org.opendaylight.netconf.shaded.sshd.common.io.nio2.Nio2Connector;
-import org.opendaylight.netconf.shaded.sshd.common.io.nio2.Nio2Session;
-
-/**
- * Custom Nio2Connector which uses NetconfNio2Session instead of Nio2Session.
- * Should be removed when SSHD-1028 is fixed.
- */
-public class NetconfNio2Connector extends Nio2Connector {
-
-    public NetconfNio2Connector(final FactoryManager manager, final IoHandler handler,
-                                final AsynchronousChannelGroup group) {
-        super(manager, handler, group);
-    }
-
-    @Override
-    protected Nio2Session createSession(final FactoryManager manager, final IoHandler handler,
-                                        final AsynchronousSocketChannel socket) throws Throwable {
-        return new NetconfNio2Session(this, manager, handler, socket, null);
-    }
-}
diff --git a/netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/handler/ssh/sshd1028/NetconfNio2ServiceFactory.java b/netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/handler/ssh/sshd1028/NetconfNio2ServiceFactory.java
deleted file mode 100644 (file)
index 3faeb0c..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright (c) 2020 PANTHEON.tech, s.r.o. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.netconf.nettyutil.handler.ssh.sshd1028;
-
-import java.lang.reflect.Field;
-import java.nio.channels.AsynchronousChannelGroup;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-import org.opendaylight.netconf.shaded.sshd.common.FactoryManager;
-import org.opendaylight.netconf.shaded.sshd.common.io.IoConnector;
-import org.opendaylight.netconf.shaded.sshd.common.io.IoHandler;
-import org.opendaylight.netconf.shaded.sshd.common.io.nio2.Nio2ServiceFactory;
-import org.opendaylight.netconf.shaded.sshd.common.util.threads.CloseableExecutorService;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Custom Nio2ServiceFactory which creates instances of NetconfNio2Connector instead of Nio2Connector.
- * Should be removed when SSHD-1028 is fixed.
- */
-public class NetconfNio2ServiceFactory extends Nio2ServiceFactory {
-    private static final Logger LOG = LoggerFactory.getLogger(NetconfNio2ServiceFactory.class);
-    private static final Field FIELD_GROUP;
-
-    static {
-        final Field fieldGroup;
-        try {
-            fieldGroup = NetconfNio2ServiceFactory.class.getSuperclass().getDeclaredField("group");
-        } catch (NoSuchFieldException e) {
-            LOG.error("Cannot access the ChannelGroup from the " + "Nio2ServiceFactory");
-            throw new ExceptionInInitializerError(e);
-        }
-
-        AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
-            fieldGroup.setAccessible(true);
-            return null;
-        });
-
-        FIELD_GROUP = fieldGroup;
-    }
-
-    public NetconfNio2ServiceFactory(final FactoryManager factoryManager, final CloseableExecutorService service) {
-        super(factoryManager, service);
-    }
-
-    @Override
-    public IoConnector createConnector(final IoHandler handler) {
-        if (FIELD_GROUP != null) {
-            try {
-                final AsynchronousChannelGroup group = (AsynchronousChannelGroup)FIELD_GROUP.get(this);
-                return autowireCreatedService(new NetconfNio2Connector(getFactoryManager(), handler, group));
-            } catch (IllegalAccessException e) {
-                LOG.error("NetconfNio2Connector cannot be instanciated. Creating default Nio2Connector instead.");
-            }
-        }
-
-        return super.createConnector(handler);
-    }
-}
diff --git a/netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/handler/ssh/sshd1028/NetconfNio2ServiceFactoryFactory.java b/netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/handler/ssh/sshd1028/NetconfNio2ServiceFactoryFactory.java
deleted file mode 100644 (file)
index b400e0c..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright (c) 2020 PANTHEON.tech, s.r.o. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.netconf.nettyutil.handler.ssh.sshd1028;
-
-import org.opendaylight.netconf.shaded.sshd.common.FactoryManager;
-import org.opendaylight.netconf.shaded.sshd.common.io.IoServiceFactory;
-import org.opendaylight.netconf.shaded.sshd.common.io.nio2.Nio2ServiceFactoryFactory;
-
-/**
- * Custom Nio2ServiceFactoryFactory which creates instances of NetconfNio2ServiceFactory instead of Nio2ServiceFactory.
- * Should be removed when SSHD-1028 is fixed.
- */
-public class NetconfNio2ServiceFactoryFactory extends Nio2ServiceFactoryFactory {
-
-    public NetconfNio2ServiceFactoryFactory() {
-        super(null);
-    }
-
-    @Override
-    public IoServiceFactory create(final FactoryManager manager) {
-        return new NetconfNio2ServiceFactory(manager, newExecutor());
-    }
-}
diff --git a/netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/handler/ssh/sshd1028/NetconfNio2Session.java b/netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/handler/ssh/sshd1028/NetconfNio2Session.java
deleted file mode 100644 (file)
index 9c6e8cf..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright (c) 2020 PANTHEON.tech, s.r.o. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.netconf.nettyutil.handler.ssh.sshd1028;
-
-import java.io.IOException;
-import java.net.SocketAddress;
-import java.nio.ByteBuffer;
-import java.nio.channels.AsynchronousSocketChannel;
-import org.opendaylight.netconf.shaded.sshd.common.FactoryManager;
-import org.opendaylight.netconf.shaded.sshd.common.io.IoHandler;
-import org.opendaylight.netconf.shaded.sshd.common.io.nio2.Nio2CompletionHandler;
-import org.opendaylight.netconf.shaded.sshd.common.io.nio2.Nio2Service;
-import org.opendaylight.netconf.shaded.sshd.common.io.nio2.Nio2Session;
-import org.opendaylight.netconf.shaded.sshd.common.util.Readable;
-
-/**
- * Custom Nio2Session which fixes the issue with connections not being properly closed.
- * Should be removed when SSHD-1028 is fixed.
- */
-public class NetconfNio2Session extends Nio2Session {
-
-    public NetconfNio2Session(final Nio2Service service, final FactoryManager manager, final IoHandler handler,
-                              final AsynchronousSocketChannel socket, final SocketAddress acceptanceAddress)
-        throws IOException {
-        super(service, manager, handler, socket, acceptanceAddress);
-    }
-
-    /**
-     * This method in sshd-osgi:2.5.0 and 2.5.1 contains a bug. The close(true) statement was removed. We can override
-     * it making a workaround for this issue - until SSHD-1028 is fixed.
-     */
-    @Override
-    @SuppressWarnings("IllegalCatch")
-    protected void handleReadCycleCompletion(final ByteBuffer buffer, final Readable bufReader,
-                                             final Nio2CompletionHandler<Integer, Object> completionHandler,
-                                             final Integer result, final Object attachment) {
-        try {
-            boolean debugEnabled = log.isDebugEnabled();
-            if (result >= 0) {
-                if (debugEnabled) {
-                    log.debug("handleReadCycleCompletion({}) read {} bytes", this, result);
-                }
-                buffer.flip();
-                IoHandler handler = getIoHandler();
-                handler.messageReceived(this, bufReader);
-                if (!closeFuture.isClosed()) {
-                    // re-use reference for next iteration since we finished processing it
-                    buffer.clear();
-                    doReadCycle(buffer, completionHandler);
-                } else {
-                    if (debugEnabled) {
-                        log.debug("handleReadCycleCompletion({}) IoSession has been closed, stop reading", this);
-                    }
-                }
-            } else {
-                if (debugEnabled) {
-                    log.debug("handleReadCycleCompletion({}) Socket has been disconnected (result={}), closing "
-                        + "IoSession now", this, result);
-                }
-                close(true);
-            }
-        } catch (Throwable exc) {
-            completionHandler.failed(exc, attachment);
-        }
-    }
-}
index 31462cb897a1ef18fc57fd3fca6a1225f7da01dd..46bce11599c61a3e525fca8e786fee2b9ed31a32 100644 (file)
@@ -205,7 +205,7 @@ public class AsyncSshHandlerTest {
         final IoInputStream asyncOut = getMockedIoInputStream();
         final IoOutputStream asyncIn = getMockedIoOutputStream();
 
-        final IoWriteFuture ioWriteFuture = asyncIn.writePacket(new ByteArrayBuffer());
+        final IoWriteFuture ioWriteFuture = asyncIn.writeBuffer(new ByteArrayBuffer());
 
         Futures.addCallback(stubAddListener(ioWriteFuture), new SuccessFutureListener<IoWriteFuture>() {
             @Override
@@ -236,7 +236,7 @@ public class AsyncSshHandlerTest {
 
         final IoInputStream asyncOut = getMockedIoInputStream();
         final IoOutputStream asyncIn = getMockedIoOutputStream();
-        final IoWriteFuture ioWriteFuture = asyncIn.writePacket(new ByteArrayBuffer());
+        final IoWriteFuture ioWriteFuture = asyncIn.writeBuffer(new ByteArrayBuffer());
 
         final NettyAwareChannelSubsystem subsystemChannel = getMockedSubsystemChannel(asyncOut, asyncIn);
         final ClientSession sshSession = getMockedSshSession(subsystemChannel);
@@ -261,7 +261,7 @@ public class AsyncSshHandlerTest {
         final ChannelPromise secondWritePromise = getMockedPromise();
         asyncSshHandler.write(ctx, Unpooled.copiedBuffer(new byte[]{0, 1, 2, 3, 4, 5}), secondWritePromise);
 
-        doReturn(ioWriteFuture).when(asyncIn).writePacket(any(Buffer.class));
+        doReturn(ioWriteFuture).when(asyncIn).writeBuffer(any(Buffer.class));
 
         verifyNoMoreInteractions(firstWritePromise, secondWritePromise);
 
@@ -283,7 +283,7 @@ public class AsyncSshHandlerTest {
 
         final IoInputStream asyncOut = getMockedIoInputStream();
         final IoOutputStream asyncIn = getMockedIoOutputStream();
-        final IoWriteFuture ioWriteFuture = asyncIn.writePacket(new ByteArrayBuffer());
+        final IoWriteFuture ioWriteFuture = asyncIn.writeBuffer(new ByteArrayBuffer());
 
         final NettyAwareChannelSubsystem subsystemChannel = getMockedSubsystemChannel(asyncOut, asyncIn);
         final ClientSession sshSession = getMockedSshSession(subsystemChannel);
@@ -303,7 +303,7 @@ public class AsyncSshHandlerTest {
 
         final ChannelPromise secondWritePromise = getMockedPromise();
         // now make write throw pending exception
-        doThrow(WritePendingException.class).when(asyncIn).writePacket(any(Buffer.class));
+        doThrow(WritePendingException.class).when(asyncIn).writeBuffer(any(Buffer.class));
         for (int i = 0; i < 1001; i++) {
             asyncSshHandler.write(ctx, Unpooled.copiedBuffer(new byte[]{0, 1, 2, 3, 4, 5}), secondWritePromise);
         }
@@ -408,7 +408,7 @@ public class AsyncSshHandlerTest {
             }
         }, MoreExecutors.directExecutor());
 
-        doReturn(ioWriteFuture).when(mock).writePacket(any(Buffer.class));
+        doReturn(ioWriteFuture).when(mock).writeBuffer(any(Buffer.class));
         doReturn(false).when(mock).isClosed();
         doReturn(false).when(mock).isClosing();
         return mock;
index 556e7f89c086ccdce92d82da46956d24b880dd70..92e330826b38e3aeeb3332e180b36e4c6f8c4fff 100644 (file)
         <dependency>
             <groupId>org.apache.sshd</groupId>
             <artifactId>sshd-osgi</artifactId>
-            <version>2.5.1</version>
+            <version>2.6.0</version>
         </dependency>
         <dependency>
             <groupId>org.apache.sshd</groupId>
             <artifactId>sshd-netty</artifactId>
-            <version>2.5.1</version>
+            <version>2.6.0</version>
             <exclusions>
                 <exclusion>
                     <groupId>org.apache.sshd</groupId>