deflater.reset(); deflater.setInput(payload, msg.getOffset(), length); deflater.finish(); deflater.deflate(compressed_payload); int compressed_size=deflater.getTotalOut();
int compressed_size; synchronized(deflater_mutex) { deflater.reset(); deflater.setInput(payload, msg.getOffset(), length); deflater.finish(); deflater.deflate(compressed_payload); compressed_size=deflater.getTotalOut(); }
    public void down(Event evt) {        if(evt.getType() == Event.MSG) {            Message msg=(Message)evt.getArg();            int length=msg.getLength(); // takes offset/length (if set) into account            if(length >= min_size) {                byte[] payload=msg.getRawBuffer(); // here we get the ref so we can avoid copying                byte[] compressed_payload=new byte[length];                deflater.reset();                deflater.setInput(payload, msg.getOffset(), length);                deflater.finish();                deflater.deflate(compressed_payload);                int compressed_size=deflater.getTotalOut();                byte[] new_payload=new byte[compressed_size];                System.arraycopy(compressed_payload, 0, new_payload, 0, compressed_size);                msg.setBuffer(new_payload);                msg.putHeader(name, new CompressHeader(length));                if(trace)                    log.trace("compressed payload from " + length + " bytes to " + compressed_size + " bytes");            }        }        passDown(evt);    }