Class JdkZlibDecompressor

    • Field Detail

      • MIN_OUTPUT_BUFFER_SIZE

        private static final int MIN_OUTPUT_BUFFER_SIZE
        Smallest output buffer we hand to Inflater.inflate(byte[], int, int). The number of remaining input bytes is only a hint for how much output to expect: the inflater may still hold decoded data that did not fit into the previous output buffer, and by then it may have consumed all input bytes already (Inflater.getRemaining() == 0). Inflating into a zero-sized buffer can never make progress.
        See Also:
        Constant Field Values
      • inflater

        private java.util.zip.Inflater inflater
      • maxAllocation

        private final int maxAllocation
      • dictionary

        private final byte[] dictionary
      • decompressConcatenated

        private final boolean decompressConcatenated
      • flags

        private int flags
      • xlen

        private int xlen
      • decideZlibOrNone

        private boolean decideZlibOrNone
      • finished

        private boolean finished
      • gzipMemberFinished

        private boolean gzipMemberFinished
      • inputBufferInInflater

        private boolean inputBufferInInflater
        If this is true, part of the input buffer is still in use by the inflater, so we shouldn't touch that buffer too much (e.g. compact it).
      • inflaterHasPendingOutput

        private boolean inflaterHasPendingOutput
        If this is true, the last Inflater.inflate(byte[], int, int) filled the output buffer completely, so the inflater may still hold decoded data even if Inflater.needsInput() reports that all input was consumed.
    • Method Detail

      • consumeInput

        private void consumeInput​(ByteBuf buf)
      • handleGzipFooter

        private boolean handleGzipFooter​(ByteBuf in)
      • readGZIPHeader

        private boolean readGZIPHeader​(ByteBuf in)
      • skipIfNeeded

        private boolean skipIfNeeded​(ByteBuf in,
                                     int flagMask)
        Skip bytes in the input if needed until we find the end marker 0x00.
        Parameters:
        in - the input
        flagMask - the mask that should be present in the flags when we need to skip bytes.
        Returns:
        true if the operation is complete and we can move to the next state, false if we need the retry again once we have more readable bytes.
      • readGZIPFooter

        private boolean readGZIPFooter​(ByteBuf in)
        Read the GZIP footer.
        Parameters:
        in - the input.
        Returns:
        true if the footer could be read, false if the read could not be performed as the input ByteBuf doesn't have enough readable bytes (8 bytes).
      • verifyCrc

        private boolean verifyCrc​(ByteBuf in)
        Verifies CRC.
        Parameters:
        in - the input.
        Returns:
        true if verification could be performed, false if verification could not be performed as the input ByteBuf doesn't have enough readable bytes (4 bytes).
      • verifyCrc16

        private boolean verifyCrc16​(ByteBuf in)
      • looksLikeZlib

        private static boolean looksLikeZlib​(short cmf_flg)
      • close

        public void close()
        Description copied from interface: Decompressor
        Close this decompressor, cleaning up any associated resources. This method is idempotent.
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface Decompressor
        Overrides:
        close in class InputBufferingDecompressor