Package org.apache.sshd.netty
Class NettyIoSession.Adapter
java.lang.Object
io.netty.channel.ChannelHandlerAdapter
io.netty.channel.ChannelInboundHandlerAdapter
org.apache.sshd.netty.NettyIoSession.Adapter
- All Implemented Interfaces:
io.netty.channel.ChannelHandler
,io.netty.channel.ChannelInboundHandler
- Enclosing class:
NettyIoSession
protected class NettyIoSession.Adapter
extends io.netty.channel.ChannelInboundHandlerAdapter
Netty adapter to use as a bridge, with extra handling for suspending reads. Netty may sometimes may deliver read
events even after reads have been suspended. Suspending reads only removes the channel for OP_READ in the next
select. But Netty's default read buffer management does not account for this, and it may deliver more events
still if there are more than 64kB available on the socket.
There is a FlowControlHandler
that should be able to handle this case if inserted
in the channel pipeline before this handler. But somehow this did not work reliably. Therefore this adapter
manages this directly by accumulating all read events in a single buffer and delivering the whole buffer once the
low-level socket read is completed.
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.netty.channel.ChannelHandler
io.netty.channel.ChannelHandler.Sharable
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
channelActive
(io.netty.channel.ChannelHandlerContext ctx) void
channelInactive
(io.netty.channel.ChannelHandlerContext ctx) void
channelRead
(io.netty.channel.ChannelHandlerContext ctx, Object msg) void
channelReadComplete
(io.netty.channel.ChannelHandlerContext ctx) void
exceptionCaught
(io.netty.channel.ChannelHandlerContext ctx, Throwable cause) Methods inherited from class io.netty.channel.ChannelInboundHandlerAdapter
channelRegistered, channelUnregistered, channelWritabilityChanged, userEventTriggered
Methods inherited from class io.netty.channel.ChannelHandlerAdapter
ensureNotSharable, handlerAdded, handlerRemoved, isSharable
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.netty.channel.ChannelHandler
handlerAdded, handlerRemoved
-
Field Details
-
buffer
private org.apache.sshd.common.util.buffer.ByteArrayBuffer buffer -
ioBuffer
private io.netty.buffer.ByteBuf ioBuffer
-
-
Constructor Details
-
Adapter
public Adapter()
-
-
Method Details
-
channelActive
- Specified by:
channelActive
in interfaceio.netty.channel.ChannelInboundHandler
- Overrides:
channelActive
in classio.netty.channel.ChannelInboundHandlerAdapter
- Throws:
Exception
-
channelInactive
- Specified by:
channelInactive
in interfaceio.netty.channel.ChannelInboundHandler
- Overrides:
channelInactive
in classio.netty.channel.ChannelInboundHandlerAdapter
- Throws:
Exception
-
channelRead
- Specified by:
channelRead
in interfaceio.netty.channel.ChannelInboundHandler
- Overrides:
channelRead
in classio.netty.channel.ChannelInboundHandlerAdapter
- Throws:
Exception
-
channelReadComplete
- Specified by:
channelReadComplete
in interfaceio.netty.channel.ChannelInboundHandler
- Overrides:
channelReadComplete
in classio.netty.channel.ChannelInboundHandlerAdapter
- Throws:
Exception
-
exceptionCaught
public void exceptionCaught(io.netty.channel.ChannelHandlerContext ctx, Throwable cause) throws Exception - Specified by:
exceptionCaught
in interfaceio.netty.channel.ChannelHandler
- Specified by:
exceptionCaught
in interfaceio.netty.channel.ChannelInboundHandler
- Overrides:
exceptionCaught
in classio.netty.channel.ChannelInboundHandlerAdapter
- Throws:
Exception
-