X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fnetconf%2Fnetconf-util%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fnetconf%2Futil%2Fhandler%2Fssh%2Fvirtualsocket%2FVirtualSocket.java;fp=opendaylight%2Fnetconf%2Fnetconf-util%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fnetconf%2Futil%2Fhandler%2Fssh%2Fvirtualsocket%2FVirtualSocket.java;h=36c2c1c3295736bf9cc183fbe53256ac847ff15b;hp=1011ca16be84803d4bfbe6f8f083335782de6538;hb=b925756421ea8565637d8575d8143dbf46db5a86;hpb=81387f0ae5898b196a54493f9bf4305993f39d1c diff --git a/opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/handler/ssh/virtualsocket/VirtualSocket.java b/opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/handler/ssh/virtualsocket/VirtualSocket.java index 1011ca16be..36c2c1c329 100644 --- a/opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/handler/ssh/virtualsocket/VirtualSocket.java +++ b/opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/handler/ssh/virtualsocket/VirtualSocket.java @@ -26,6 +26,9 @@ import java.nio.channels.SocketChannel; * are able to use full potential of NIO environment. */ public class VirtualSocket extends Socket implements ChannelHandler { + private static final String INPUT_STREAM = "inputStream"; + private static final String OUTPUT_STREAM = "outputStream"; + private final ChannelInputStream chis = new ChannelInputStream(); private final ChannelOutputStream chos = new ChannelOutputStream(); private ChannelHandlerContext ctx; @@ -39,29 +42,30 @@ public class VirtualSocket extends Socket implements ChannelHandler { return this.chos; } - public void handlerAdded(ChannelHandlerContext ctx) throws Exception { + public void handlerAdded(ChannelHandlerContext ctx) { this.ctx = ctx; - if (ctx.channel().pipeline().get("outputStream") == null) { - ctx.channel().pipeline().addFirst("outputStream", chos); + if (ctx.channel().pipeline().get(OUTPUT_STREAM) == null) { + ctx.channel().pipeline().addFirst(OUTPUT_STREAM, chos); } - if (ctx.channel().pipeline().get("inputStream") == null) { - ctx.channel().pipeline().addFirst("inputStream", chis); + if (ctx.channel().pipeline().get(INPUT_STREAM) == null) { + ctx.channel().pipeline().addFirst(INPUT_STREAM, chis); } } - public void handlerRemoved(ChannelHandlerContext ctx) throws Exception { - if (ctx.channel().pipeline().get("outputStream") != null) { - ctx.channel().pipeline().remove("outputStream"); + public void handlerRemoved(ChannelHandlerContext ctx) { + if (ctx.channel().pipeline().get(OUTPUT_STREAM) != null) { + ctx.channel().pipeline().remove(OUTPUT_STREAM); } - if (ctx.channel().pipeline().get("inputStream") != null) { - ctx.channel().pipeline().remove("inputStream"); + if (ctx.channel().pipeline().get(INPUT_STREAM) != null) { + ctx.channel().pipeline().remove(INPUT_STREAM); } } - public void exceptionCaught(ChannelHandlerContext ctx, Throwable throwable) throws Exception { + public void exceptionCaught(ChannelHandlerContext ctx, Throwable throwable) { + // TODO exceptionCaught is deprecated transform this handler ctx.fireExceptionCaught(throwable); } @@ -80,7 +84,9 @@ public class VirtualSocket extends Socket implements ChannelHandler { public InetAddress getInetAddress() { InetSocketAddress isa = getInetSocketAddress(); - if (isa == null) throw new VirtualSocketException(); + if (isa == null) { + throw new VirtualSocketException(); + } return getInetSocketAddress().getAddress(); }