public static byte[] compress(byte[] in) {
        if (in == null) {
            throw new NullPointerException("Can't compress null");
        }

        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        GZIPOutputStream      gz  = null;

        try {
            gz = new GZIPOutputStream(bos);
            gz.write(in);
        } catch (IOException e) {
            throw new RuntimeException("IO exception compressing data", e);
        } finally {
            try {
                gz.close();
                bos.close();
            } catch (Exception e) {
                // should not happen
            }
        }

        byte[] rv = bos.toByteArray();

        if (log.isInfoEnabled()) {
            log.info("compressed value, size from [" + in.length + "] to [" + rv.length + "]");
        }

        return rv;
    }