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 f4203c4339
commit ec8d43c294

View File

@ -2183,7 +2183,11 @@ public class SslHandler extends ByteToMessageDecoder implements ChannelOutboundH
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) {