@Override
    public void close() throws IOException {
        if (!open) {
            return;
        }
        Deflater localDeflater = deflater;
        ByteBuffer localTempOut = tempOut;
        FileChannel localChannel = channel;
        try {
            if (localDeflater.finished()) {
                writeTrailer();
            } else {
                localDeflater.finish();
                while (true) {
                    int written = localDeflater.deflate(localTempOut);
                    if (written > 0) {
                        localTempOut.flip();
                        localChannel.write(localTempOut);
                        localTempOut.clear();
                    }
                    if (localDeflater.finished()) {
                        writeTrailer();
                        break;
                    }
                }
            }
        } finally {
            crc.reset();
            localDeflater.reset();
            localTempOut.clear();
            open = false;
            localChannel.close();
        }
    }
This class has a better performance than {@link GZIPOutputStream} because the class: 1. uses
(direct) ByteBuffer instead of byte[] 2. caches and reuse data 3. no synchronized on our own
methods

@author James Chen
@see java.util.zip.DeflaterOutputStream
@see java.util.zip.GZIPOutputStream
turms-server-common/src/main/java/im/turms/server/common/infra/logging/core/compression/FastGzipOutputStream.java