Class ZlibDecoder

All Implemented Interfaces:
ChannelHandler, ChannelInboundHandler
Direct Known Subclasses:
JdkZlibDecoder, JZlibDecoder

public abstract class ZlibDecoder extends ByteToMessageDecoder
Decompresses a ByteBuf using the deflate algorithm.
  • Field Details

    • maxAllocation

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

    • 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 Details

    • isClosed

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

      protected ByteBuf prepareDecompressBuffer(ChannelHandlerContext ctx, 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(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.