session.removeAttribute(DISABLE_COMPRESSION_ONCE);
nextFilter.filterWrite(session, writeRequest);
return;
}
Zlib deflater = (Zlib) session.getAttribute(DEFLATER);
if (deflater == null) {
throw new IllegalStateException();
}
ByteBuffer inBuffer = (ByteBuffer) writeRequest.getMessage();
if (!inBuffer.hasRemaining()) {
// Ignore empty buffers
nextFilter.filterWrite(session, writeRequest);
} else {
ByteBuffer outBuf = deflater.deflate(inBuffer);
inBuffer.release();
nextFilter.filterWrite(session, new WriteRequest(outBuf,
writeRequest.getFuture()));
}
}