Do not mandate direct bytes in SslHandler queue (#9656)

Motivation:

Currently when the SslHandler coalesces outbound bytes it always
allocates a direct byte buffer. This does not make sense if the JDK
engine is being used as the bytes will have to be copied back to heap
bytes for the engine to operate on them.

Modifications:

Inspect engine type when coalescing outbound bytes and allocate heap
buffer if heap bytes are preferred by the engine.

Result:

Improved performance for JDK engine. Better performance in environments
without direct buffer pooling.
This commit is contained in:
Tim Brooks 2019-10-12 12:12:13 -06:00 committed by Norman Maurer
parent 665cdf1ec4
commit 678983f2a7

View File

@ -2137,7 +2137,11 @@ public class SslHandler extends ByteToMessageDecoder {
protected ByteBuf composeFirst(ByteBufAllocator allocator, ByteBuf first) {
if (first instanceof CompositeByteBuf) {
CompositeByteBuf composite = (CompositeByteBuf) first;
first = allocator.directBuffer(composite.readableBytes());
if (engineType.wantsDirectBuffer) {
first = allocator.directBuffer(composite.readableBytes());
} else {
first = allocator.heapBuffer(composite.readableBytes());
}
try {
first.writeBytes(composite);
} catch (Throwable cause) {