SslHandlerCoalescingBufferQueue Class — netty Architecture
Architecture documentation for the SslHandlerCoalescingBufferQueue class in SslHandlerCoalescingBufferQueue.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 0aa60ec9_89c3_e36b_309b_e98e165de0ee["SslHandlerCoalescingBufferQueue"] ee5abe13_dbbc_7dd5_e495_7c17d05668f5["SslHandlerCoalescingBufferQueue.java"] 0aa60ec9_89c3_e36b_309b_e98e165de0ee -->|defined in| ee5abe13_dbbc_7dd5_e495_7c17d05668f5 b3e25ab2_c29d_3e6d_826c_587bfd5c7d27["SslHandlerCoalescingBufferQueue()"] 0aa60ec9_89c3_e36b_309b_e98e165de0ee -->|method| b3e25ab2_c29d_3e6d_826c_587bfd5c7d27 4e015cdc_d317_4bcc_9e74_a43e544c8cce["wrapDataSize()"] 0aa60ec9_89c3_e36b_309b_e98e165de0ee -->|method| 4e015cdc_d317_4bcc_9e74_a43e544c8cce 1dcb9da8_a682_a2a6_431c_dc8d6b126e8a["ByteBuf()"] 0aa60ec9_89c3_e36b_309b_e98e165de0ee -->|method| 1dcb9da8_a682_a2a6_431c_dc8d6b126e8a 434aea79_d1fd_2294_f710_61b9ad4f9245["attemptCopyToCumulation()"] 0aa60ec9_89c3_e36b_309b_e98e165de0ee -->|method| 434aea79_d1fd_2294_f710_61b9ad4f9245
Relationship Graph
Source Code
handler/src/main/java/io/netty/handler/ssl/SslHandlerCoalescingBufferQueue.java lines 32–94
abstract class SslHandlerCoalescingBufferQueue extends AbstractCoalescingBufferQueue {
private final boolean wantsDirectBuffer;
SslHandlerCoalescingBufferQueue(Channel channel, int initSize, boolean wantsDirectBuffer) {
super(channel, initSize);
this.wantsDirectBuffer = wantsDirectBuffer;
}
protected abstract int wrapDataSize();
@Override
protected ByteBuf compose(ByteBufAllocator alloc, ByteBuf cumulation, ByteBuf next) {
return attemptCopyToCumulation(cumulation, next, wrapDataSize()) ? cumulation :
copyAndCompose(alloc, cumulation, next);
}
@Override
protected ByteBuf composeFirst(ByteBufAllocator allocator, ByteBuf first, int bufferSize) {
final ByteBuf newFirst;
if (wantsDirectBuffer) {
newFirst = allocator.directBuffer(bufferSize);
} else {
newFirst = allocator.heapBuffer(bufferSize);
}
try {
newFirst.writeBytes(first);
} catch (Throwable cause) {
newFirst.release();
PlatformDependent.throwException(cause);
}
assert !first.isReadable();
first.release();
return newFirst;
}
@Override
protected ByteBuf removeEmptyValue() {
return null;
}
private static boolean attemptCopyToCumulation(ByteBuf cumulation, ByteBuf next, int wrapDataSize) {
final int inReadableBytes = next.readableBytes();
// Nothing to copy so just release the buffer.
if (inReadableBytes == 0) {
next.release();
return true;
}
final int cumulationCapacity = cumulation.capacity();
if (wrapDataSize - cumulation.readableBytes() >= inReadableBytes &&
// Avoid using the same buffer if next's data would make cumulation exceed the wrapDataSize.
// Only copy if there is enough space available and the capacity is large enough, and attempt to
// resize if the capacity is small.
(cumulation.isWritable(inReadableBytes) && cumulationCapacity >= wrapDataSize ||
cumulationCapacity < wrapDataSize &&
ensureWritableSuccess(cumulation.ensureWritable(inReadableBytes, false)))) {
cumulation.writeBytes(next);
next.release();
return true;
}
return false;
}
}
Source
Frequently Asked Questions
What is the SslHandlerCoalescingBufferQueue class?
SslHandlerCoalescingBufferQueue is a class in the netty codebase, defined in handler/src/main/java/io/netty/handler/ssl/SslHandlerCoalescingBufferQueue.java.
Where is SslHandlerCoalescingBufferQueue defined?
SslHandlerCoalescingBufferQueue is defined in handler/src/main/java/io/netty/handler/ssl/SslHandlerCoalescingBufferQueue.java at line 32.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free