public static byte[] compress(byte[] data) {
        if (data == null || data.length == 0) {
            return data;
        }

        ByteArrayOutputStream out = new ByteArrayOutputStream();
        GZIPOutputStream gzip = null;
        try {
            gzip = new GZIPOutputStream(out);
            gzip.write(data);
        } catch (IOException e) {
            LOG.error("compress data error", e);
        } finally {
            if (gzip != null) {
                try {
                    gzip.close();
                } catch (IOException e) {
                    LOG.error(GzipUtils.class.getSimpleName(), e);
                }
            }
        }

        return out.toByteArray();
    }
compress

@param  data
@return      byte array
inlong-sdk/sdk-common/src/main/java/org/apache/inlong/sdk/commons/utils/GzipUtils.java