Fix bug introduced in
412e6b4 by reverting back to previous state.
Also fix a resource leak in writeImpl.
Change-Id: If43741071d1471280491888078f342bc33269c5f
Signed-off-by: Tomas Olvecky <tolvecky@cisco.com>
- SshSession session;
- try {
- session = sshClient.openSession();
- } catch (IOException e) {
- logger.error("Cannot establish session", e);
- sshClient.close();
- return;
- }
+ SshSession session = sshClient.openSession();
invoker.invoke(session);
InputStream stdOut = session.getStdout();
session.getStderr();
invoker.invoke(session);
InputStream stdOut = session.getStdout();
session.getStderr();
} catch (VirtualSocketException e) {
// Netty closed connection prematurely.
} 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);
// Just pass and move on.
} catch (Exception e) {
logger.error("Unexpected exception", e);
private void writeImpl(ByteBuf message) throws IOException {
message.getBytes(0, stdIn, message.readableBytes());
private void writeImpl(ByteBuf message) throws IOException {
message.getBytes(0, stdIn, message.readableBytes());
/**
* Exception class which provides notification about exceptional situations at the virtual socket layer.
*/
/**
* 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;
}
public class VirtualSocketException extends RuntimeException {
private static final long serialVersionUID = 1L;
}