From: Tony Tkacik Date: Wed, 25 Jun 2014 09:51:20 +0000 (+0000) Subject: Merge "Bug:1238 - Revert changes to SshClientAdapter." X-Git-Tag: release/helium~605 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=commitdiff_plain;h=ad38b2defabd924505f1624947ff626ad441f8e1;hp=af01f3ff581487d002140ca08a94e4636546d649 Merge "Bug:1238 - Revert changes to SshClientAdapter." --- 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 cf4ec213c2..ad8b25ff21 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 @@ -52,15 +52,8 @@ 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(); @@ -90,6 +83,8 @@ public class SshClientAdapter implements Runnable { } catch (VirtualSocketException e) { // Netty closed connection prematurely. + // Or maybe tried to open ganymed connection without having initialized session + // (ctx.channel().remoteAddress() is null) // Just pass and move on. } catch (Exception e) { logger.error("Unexpected exception", e); @@ -117,6 +112,7 @@ public class SshClientAdapter implements Runnable { private void writeImpl(ByteBuf message) throws IOException { message.getBytes(0, stdIn, message.readableBytes()); + message.release(); stdIn.flush(); } diff --git a/opendaylight/netconf/netconf-netty-util/src/main/java/org/opendaylight/controller/netconf/nettyutil/handler/ssh/virtualsocket/VirtualSocketException.java b/opendaylight/netconf/netconf-netty-util/src/main/java/org/opendaylight/controller/netconf/nettyutil/handler/ssh/virtualsocket/VirtualSocketException.java index d97990a5e6..626ebe937e 100644 --- a/opendaylight/netconf/netconf-netty-util/src/main/java/org/opendaylight/controller/netconf/nettyutil/handler/ssh/virtualsocket/VirtualSocketException.java +++ b/opendaylight/netconf/netconf-netty-util/src/main/java/org/opendaylight/controller/netconf/nettyutil/handler/ssh/virtualsocket/VirtualSocketException.java @@ -11,6 +11,7 @@ package org.opendaylight.controller.netconf.nettyutil.handler.ssh.virtualsocket; /** * Exception class which provides notification about exceptional situations at the virtual socket layer. */ +// FIXME: Switch to checked exception, create a runtime exception to workaround Socket API public class VirtualSocketException extends RuntimeException { private static final long serialVersionUID = 1L; }