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;
}
@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;
}
}
@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");
}
@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();
clientBootstrap.handler(new ChannelInitializer<LocalChannel>() {
@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<ChannelFuture>() {
-
- @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());
}
});
}
clientChannelFuture.cancel(true);
if (clientChannel != null) {
- clientChannel.close().addListener(new GenericFutureListener<ChannelFuture>() {
-
- @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);
}
});
}