Class CompatibleMarshallingDecoder

java.lang.Object
io.netty.channel.ChannelHandlerAdapter
io.netty.channel.ChannelInboundHandlerAdapter
io.netty.handler.codec.ByteToMessageDecoder
io.netty.handler.codec.ReplayingDecoder<Void>
io.netty.handler.codec.marshalling.CompatibleMarshallingDecoder
All Implemented Interfaces:
io.netty.channel.ChannelHandler, io.netty.channel.ChannelInboundHandler

public class CompatibleMarshallingDecoder extends ReplayingDecoder<Void>
ReplayingDecoder which use an Unmarshaller to read the Object out of the ByteBuf. If you can you should use MarshallingDecoder.
  • Field Details

    • provider

      protected final UnmarshallerProvider provider
    • maxObjectSize

      protected final int maxObjectSize
  • Constructor Details

    • CompatibleMarshallingDecoder

      public CompatibleMarshallingDecoder(UnmarshallerProvider provider, int maxObjectSize)
      Create a new instance of CompatibleMarshallingDecoder.
      Parameters:
      provider - the UnmarshallerProvider which is used to obtain the Unmarshaller for the Channel
      maxObjectSize - the maximal size (in bytes) of the Object to unmarshal. Once the size is exceeded the Channel will get closed. Use a maxObjectSize of Integer.MAX_VALUE to disable this. You should only do this if you are sure that the received Objects will never be big and the sending side are trusted, as this opens the possibility for a DOS-Attack due an OutOfMemoryError.
  • Method Details

    • decode

      protected void decode(io.netty.channel.ChannelHandlerContext ctx, io.netty.buffer.ByteBuf buffer, List<Object> out) throws Exception
      Description copied from class: ByteToMessageDecoder
      Decode the from one ByteBuf to an other. This method will be called till either the input ByteBuf has nothing to read when return from this method or till nothing was read from the input ByteBuf.
      Specified by:
      decode in class ByteToMessageDecoder
      Parameters:
      ctx - the ChannelHandlerContext which this ByteToMessageDecoder belongs to
      buffer - the ByteBuf from which to read data
      out - the List to which decoded messages should be added
      Throws:
      Exception - is thrown if an error occurs
    • decodeLast

      protected void decodeLast(io.netty.channel.ChannelHandlerContext ctx, io.netty.buffer.ByteBuf buffer, List<Object> out) throws Exception
      Description copied from class: ByteToMessageDecoder
      Is called one last time when the ChannelHandlerContext goes in-active. Which means the ByteToMessageDecoder.channelInactive(ChannelHandlerContext) was triggered. By default, this will just call ByteToMessageDecoder.decode(ChannelHandlerContext, ByteBuf, List) but sub-classes may override this for some special cleanup operation.
      Overrides:
      decodeLast in class ByteToMessageDecoder
      Throws:
      Exception
    • exceptionCaught

      public void exceptionCaught(io.netty.channel.ChannelHandlerContext ctx, Throwable cause) throws Exception
      Specified by:
      exceptionCaught in interface io.netty.channel.ChannelHandler
      Specified by:
      exceptionCaught in interface io.netty.channel.ChannelInboundHandler
      Overrides:
      exceptionCaught in class io.netty.channel.ChannelInboundHandlerAdapter
      Throws:
      Exception