Class ZlibDecoder

  • All Implemented Interfaces:
    io.netty.channel.ChannelHandler, io.netty.channel.ChannelInboundHandler
    Direct Known Subclasses:
    JdkZlibDecoder, JZlibDecoder

    public abstract class ZlibDecoder
    extends io.netty.handler.codec.ByteToMessageDecoder
    Decompresses a ByteBuf using the deflate algorithm.
    • Nested Class Summary

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

        io.netty.handler.codec.ByteToMessageDecoder.Cumulator
      • Nested classes/interfaces inherited from interface io.netty.channel.ChannelHandler

        io.netty.channel.ChannelHandler.Sharable
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected int maxAllocation
      Maximum allowed size of the decompression buffer.
      • Fields inherited from class io.netty.handler.codec.ByteToMessageDecoder

        COMPOSITE_CUMULATOR, MERGE_CUMULATOR
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      protected void decompressionBufferExhausted​(io.netty.buffer.ByteBuf buffer)
      Called when the decompression buffer cannot be expanded further.
      abstract boolean isClosed()
      Returns true if and only if the end of the compressed stream has been reached.
      protected io.netty.buffer.ByteBuf prepareDecompressBuffer​(io.netty.channel.ChannelHandlerContext ctx, io.netty.buffer.ByteBuf buffer, int preferredSize)
      Allocate or expand the decompression buffer, without exceeding the maximum allocation.
      • Methods inherited from class io.netty.handler.codec.ByteToMessageDecoder

        actualReadableBytes, callDecode, channelInactive, channelRead, channelReadComplete, decode, decodeLast, discardSomeReadBytes, handlerRemoved, handlerRemoved0, internalBuffer, isSingleDecode, setCumulator, setDiscardAfterReads, setSingleDecode, userEventTriggered
      • Methods inherited from class io.netty.channel.ChannelInboundHandlerAdapter

        channelActive, channelRegistered, channelUnregistered, channelWritabilityChanged, exceptionCaught
      • Methods inherited from class io.netty.channel.ChannelHandlerAdapter

        ensureNotSharable, handlerAdded, isSharable
      • Methods inherited from interface io.netty.channel.ChannelHandler

        handlerAdded
    • Field Detail

      • maxAllocation

        protected final int maxAllocation
        Maximum allowed size of the decompression buffer.
    • Constructor Detail

      • ZlibDecoder

        public ZlibDecoder()
        Same as ZlibDecoder(int) with maxAllocation = 0.
      • ZlibDecoder

        public ZlibDecoder​(int maxAllocation)
        Construct a new ZlibDecoder.
        Parameters:
        maxAllocation - Maximum size of the decompression buffer. Must be >= 0. If zero, maximum size is decided by the ByteBufAllocator.
    • Method Detail

      • isClosed

        public abstract boolean isClosed()
        Returns true if and only if the end of the compressed stream has been reached.
      • prepareDecompressBuffer

        protected io.netty.buffer.ByteBuf prepareDecompressBuffer​(io.netty.channel.ChannelHandlerContext ctx,
                                                                  io.netty.buffer.ByteBuf buffer,
                                                                  int preferredSize)
        Allocate or expand the decompression buffer, without exceeding the maximum allocation. Calls decompressionBufferExhausted(ByteBuf) if the buffer is full and cannot be expanded further.
      • decompressionBufferExhausted

        protected void decompressionBufferExhausted​(io.netty.buffer.ByteBuf buffer)
        Called when the decompression buffer cannot be expanded further. Default implementation is a no-op, but subclasses can override in case they want to do something before the DecompressionException is thrown, such as log the data that was decompressed so far.