X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=netconf%2Fnetconf-ssh%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fnetconf%2Fssh%2FRemoteNetconfCommand.java;h=733d81af1ffc11b7676767ad07e6cade8a1ecc9f;hb=ce8ad4e92f8128750f7ce7216f7e73ad238efaae;hp=b5a6355d2990c6c26926b6a3fae1280af89dce85;hpb=9cc422be10034f5f3cfa401fc20539c560aa7fe3;p=netconf.git diff --git a/netconf/netconf-ssh/src/main/java/org/opendaylight/netconf/ssh/RemoteNetconfCommand.java b/netconf/netconf-ssh/src/main/java/org/opendaylight/netconf/ssh/RemoteNetconfCommand.java index b5a6355d29..733d81af1f 100644 --- a/netconf/netconf-ssh/src/main/java/org/opendaylight/netconf/ssh/RemoteNetconfCommand.java +++ b/netconf/netconf-ssh/src/main/java/org/opendaylight/netconf/ssh/RemoteNetconfCommand.java @@ -16,8 +16,6 @@ import io.netty.channel.ChannelInitializer; import io.netty.channel.EventLoopGroup; import io.netty.channel.local.LocalAddress; import io.netty.channel.local.LocalChannel; -import io.netty.util.concurrent.GenericFutureListener; -import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.net.InetSocketAddress; @@ -63,11 +61,13 @@ public class RemoteNetconfCommand implements AsyncCommand, SessionAware { } @Override + @SuppressWarnings("checkstyle:hiddenField") public void setIoInputStream(final IoInputStream in) { this.in = in; } @Override + @SuppressWarnings("checkstyle:hiddenField") public void setIoOutputStream(final IoOutputStream out) { this.out = out; } @@ -78,11 +78,13 @@ public class RemoteNetconfCommand implements AsyncCommand, SessionAware { } @Override + @SuppressWarnings("checkstyle:hiddenField") public void setInputStream(final InputStream in) { throw new UnsupportedOperationException("Synchronous IO is unsupported"); } @Override + @SuppressWarnings("checkstyle:hiddenField") public void setOutputStream(final OutputStream out) { throw new UnsupportedOperationException("Synchronous IO is unsupported"); @@ -95,12 +97,13 @@ public class RemoteNetconfCommand implements AsyncCommand, SessionAware { } @Override + @SuppressWarnings("checkstyle:hiddenField") public void setExitCallback(final ExitCallback callback) { this.callback = callback; } @Override - public void start(final Environment env) throws IOException { + public void start(final Environment env) { LOG.trace("Establishing internal connection to netconf server for client: {}", getClientAddress()); final Bootstrap clientBootstrap = new Bootstrap(); @@ -108,25 +111,21 @@ public class RemoteNetconfCommand implements AsyncCommand, SessionAware { clientBootstrap.handler(new ChannelInitializer() { @Override - public void initChannel(final LocalChannel ch) throws Exception { + public void initChannel(final LocalChannel ch) { ch.pipeline() .addLast(new SshProxyClientHandler(in, out, netconfHelloMessageAdditionalHeader, callback)); } }); clientChannelFuture = clientBootstrap.connect(localAddress); - clientChannelFuture.addListener(new GenericFutureListener() { - - @Override - public void operationComplete(final ChannelFuture future) throws Exception { - if (future.isSuccess()) { - clientChannel = clientChannelFuture.channel(); - } else { - LOG.warn("Unable to establish internal connection to netconf server for client: {}", - getClientAddress()); - Preconditions.checkNotNull(callback, "Exit callback must be set"); - callback.onExit(1, "Unable to establish internal connection to netconf server for client: " - + getClientAddress()); - } + clientChannelFuture.addListener(future -> { + if (future.isSuccess()) { + clientChannel = clientChannelFuture.channel(); + } else { + LOG.warn("Unable to establish internal connection to netconf server for client: {}", + getClientAddress()); + Preconditions.checkNotNull(callback, "Exit callback must be set"); + callback.onExit(1, "Unable to establish internal connection to netconf server for client: " + + getClientAddress()); } }); } @@ -138,14 +137,10 @@ public class RemoteNetconfCommand implements AsyncCommand, SessionAware { clientChannelFuture.cancel(true); if (clientChannel != null) { - clientChannel.close().addListener(new GenericFutureListener() { - - @Override - public void operationComplete(final ChannelFuture future) throws Exception { - if (future.isSuccess() == false) { - LOG.warn("Unable to release internal connection to netconf server on channel: {}", - clientChannel); - } + clientChannel.close().addListener(future -> { + if (!future.isSuccess()) { + LOG.warn("Unable to release internal connection to netconf server on channel: {}", + clientChannel); } }); }