Class ObjectDecoder

  • All Implemented Interfaces:
    io.netty5.channel.ChannelHandler

    public class ObjectDecoder
    extends io.netty5.handler.codec.LengthFieldBasedFrameDecoder
    A decoder which deserializes the received Buffers into Java objects.

    Please note that the serialized form this decoder expects is not compatible with the standard ObjectOutputStream. Please use ObjectEncoder or ObjectEncoderOutputStream to ensure the interoperability with this decoder.

    • Nested Class Summary

      • Nested classes/interfaces inherited from class io.netty5.handler.codec.ByteToMessageDecoder

        io.netty5.handler.codec.ByteToMessageDecoder.Cumulator
    • Field Summary

      • Fields inherited from class io.netty5.handler.codec.ByteToMessageDecoder

        COMPOSITE_CUMULATOR, MERGE_CUMULATOR
    • Constructor Summary

      Constructors 
      Constructor Description
      ObjectDecoder​(int maxObjectSize, ClassResolver classResolver)
      Creates a new decoder with the specified maximum object size.
      ObjectDecoder​(ClassResolver classResolver)
      Creates a new decoder whose maximum object size is 1048576 bytes.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected Object decode0​(io.netty5.channel.ChannelHandlerContext ctx, io.netty5.buffer.Buffer in)  
      • Methods inherited from class io.netty5.handler.codec.LengthFieldBasedFrameDecoder

        decode, extractFrame, getUnadjustedFrameLength
      • Methods inherited from class io.netty5.handler.codec.ByteToMessageDecoder

        actualReadableBytes, channelInactive, channelRead, channelReadComplete, channelShutdown, decodeLast, discardSomeReadBytes, handlerAdded, handlerAdded0, handlerRemoved, handlerRemoved0, internalBuffer, isSharable, isSingleDecode, setSingleDecode
      • Methods inherited from interface io.netty5.channel.ChannelHandler

        bind, channelActive, channelExceptionCaught, channelInboundEvent, channelRegistered, channelUnregistered, channelWritabilityChanged, close, connect, deregister, disconnect, flush, pendingOutboundBytes, read, register, sendOutboundEvent, shutdown, write
    • Constructor Detail

      • ObjectDecoder

        public ObjectDecoder​(ClassResolver classResolver)
        Creates a new decoder whose maximum object size is 1048576 bytes. If the size of the received object is greater than 1048576 bytes, a StreamCorruptedException will be raised.
        Parameters:
        classResolver - the ClassResolver to use for this decoder
      • ObjectDecoder

        public ObjectDecoder​(int maxObjectSize,
                             ClassResolver classResolver)
        Creates a new decoder with the specified maximum object size.
        Parameters:
        maxObjectSize - the maximum byte length of the serialized object. if the length of the received object is greater than this value, StreamCorruptedException will be raised.
        classResolver - the ClassResolver which will load the class of the serialized object
    • Method Detail

      • decode0

        protected Object decode0​(io.netty5.channel.ChannelHandlerContext ctx,
                                 io.netty5.buffer.Buffer in)
                          throws Exception
        Overrides:
        decode0 in class io.netty5.handler.codec.LengthFieldBasedFrameDecoder
        Throws:
        Exception