X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=netconf%2Fnetconf-netty-util%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fnetconf%2Fnettyutil%2Fhandler%2Fssh%2Fclient%2FAsyncSshHandlerReader.java;h=e6ba03155580090ad5e6fa336cbf2b287238ca69;hb=d1a112edda4fa487522010a6330f67defe6359a4;hp=a6da457153b6ea98321da9f220cdecceed705cea;hpb=4c0c091813aea131d32dc70c5121a450eb9b7291;p=netconf.git diff --git a/netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/handler/ssh/client/AsyncSshHandlerReader.java b/netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/handler/ssh/client/AsyncSshHandlerReader.java index a6da457153..e6ba031555 100644 --- a/netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/handler/ssh/client/AsyncSshHandlerReader.java +++ b/netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/handler/ssh/client/AsyncSshHandlerReader.java @@ -10,10 +10,11 @@ package org.opendaylight.netconf.nettyutil.handler.ssh.client; import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled; -import org.apache.sshd.common.future.SshFutureListener; -import org.apache.sshd.common.io.IoInputStream; -import org.apache.sshd.common.io.IoReadFuture; -import org.apache.sshd.common.util.Buffer; +import org.opendaylight.netconf.shaded.sshd.common.future.SshFutureListener; +import org.opendaylight.netconf.shaded.sshd.common.io.IoInputStream; +import org.opendaylight.netconf.shaded.sshd.common.io.IoReadFuture; +import org.opendaylight.netconf.shaded.sshd.common.util.buffer.Buffer; +import org.opendaylight.netconf.shaded.sshd.common.util.buffer.ByteArrayBuffer; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -25,7 +26,7 @@ public final class AsyncSshHandlerReader implements SshFutureListener 0) { + return true; + } else if (future.getRead() > 0) { final ByteBuf msg = Unpooled.wrappedBuffer(buf.array(), 0, future.getRead()); - if(LOG.isTraceEnabled()) { - LOG.trace("Reading message on channel: {}, message: {}", channelId, AsyncSshHandlerWriter.byteBufToString(msg)); + if (LOG.isTraceEnabled()) { + LOG.trace("Reading message on channel: {}, message: {}", + channelId, AsyncSshHandlerWriter.byteBufToString(msg)); } readHandler.onMessageRead(msg); // Schedule next read - buf = new Buffer(BUFFER_SIZE); + buf = new ByteArrayBuffer(BUFFER_SIZE); currentReadFuture = asyncOut.read(buf); currentReadFuture.addListener(this); } + return false; } + /** + * Closing of the {@link AsyncSshHandlerReader}. This method should never be called with any locks held since + * call to {@link AutoCloseable#close()} can be a source of ABBA deadlock. + */ + @SuppressWarnings("checkstyle:IllegalCatch") private void invokeDisconnect() { try { connectionClosedCallback.close(); @@ -89,7 +100,7 @@ public final class AsyncSshHandlerReader implements SshFutureListener