X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fnetconf%2Fnetconf-netty-util%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fnetconf%2Fnettyutil%2Fhandler%2Fssh%2Fclient%2FSshClientAdapter.java;fp=opendaylight%2Fnetconf%2Fnetconf-netty-util%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fnetconf%2Fnettyutil%2Fhandler%2Fssh%2Fclient%2FSshClientAdapter.java;h=cf4ec213c296bbd103dfe75f7650670b008aa041;hb=412e6b4547f4925eec30a4001a3c2203424ba18f;hp=87056db06c23aef8de11c2fe80d919fffbade208;hpb=9d7a3392097e4c4a648327f77d7ca1a6aaf1b410;p=controller.git diff --git a/opendaylight/netconf/netconf-netty-util/src/main/java/org/opendaylight/controller/netconf/nettyutil/handler/ssh/client/SshClientAdapter.java b/opendaylight/netconf/netconf-netty-util/src/main/java/org/opendaylight/controller/netconf/nettyutil/handler/ssh/client/SshClientAdapter.java index 87056db06c..cf4ec213c2 100644 --- a/opendaylight/netconf/netconf-netty-util/src/main/java/org/opendaylight/controller/netconf/nettyutil/handler/ssh/client/SshClientAdapter.java +++ b/opendaylight/netconf/netconf-netty-util/src/main/java/org/opendaylight/controller/netconf/nettyutil/handler/ssh/client/SshClientAdapter.java @@ -12,7 +12,6 @@ import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled; import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelPromise; - import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; @@ -20,6 +19,8 @@ import java.util.LinkedList; import java.util.Queue; import java.util.concurrent.atomic.AtomicBoolean; import org.opendaylight.controller.netconf.nettyutil.handler.ssh.virtualsocket.VirtualSocketException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** @@ -27,6 +28,8 @@ import org.opendaylight.controller.netconf.nettyutil.handler.ssh.virtualsocket.V * pipeline. */ public class SshClientAdapter implements Runnable { + private static final Logger logger = LoggerFactory.getLogger(SshClientAdapter.class); + private static final int BUFFER_SIZE = 1024; private final SshClient sshClient; @@ -49,8 +52,15 @@ public class SshClientAdapter implements Runnable { } public void run() { + SshSession session; + try { + session = sshClient.openSession(); + } catch (IOException e) { + logger.error("Cannot establish session", e); + sshClient.close(); + return; + } try { - SshSession session = sshClient.openSession(); invoker.invoke(session); InputStream stdOut = session.getStdout(); session.getStderr(); @@ -82,7 +92,7 @@ public class SshClientAdapter implements Runnable { // Netty closed connection prematurely. // Just pass and move on. } catch (Exception e) { - throw new IllegalStateException(e); + logger.error("Unexpected exception", e); } finally { sshClient.close();