Deflater deflater=deflater_pool[tmp_index]; // must be guaranteed to be non-null !
synchronized(deflater) {
deflater.reset();
deflater.setInput(payload, msg.getOffset(), length);
deflater.finish();
deflater.deflate(compressed_payload);
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);