int compressedLength = deflater.deflate(compressedData);
deflater.reset();
if (compressedLength == 0) {
// compression failed in some weird way
throw new EncoderException("Failed to compress message of size " + length);
} else if (compressedLength >= length) {
// compression increased the size. threshold is probably too low
// send as an uncompressed packet
ByteBufUtils.writeVarInt(prefixBuf, 0);
msg.readerIndex(index);