shouldFireChannelWritabilityChangedAfterRemoval() — netty Function Reference
Architecture documentation for the shouldFireChannelWritabilityChangedAfterRemoval() function in PendingWriteQueueTest.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 534b3014_fb43_b7da_6519_934d27b7ca9d["shouldFireChannelWritabilityChangedAfterRemoval()"] b4bff24e_be13_7693_4ece_a0ed5ee1a982["PendingWriteQueueTest"] 534b3014_fb43_b7da_6519_934d27b7ca9d -->|defined in| b4bff24e_be13_7693_4ece_a0ed5ee1a982 21f29e3d_6bf2_8663_b27c_0cf9f480f48f["EmbeddedChannel()"] 534b3014_fb43_b7da_6519_934d27b7ca9d -->|calls| 21f29e3d_6bf2_8663_b27c_0cf9f480f48f 3c318cdf_c917_da17_c963_7ace79e37c0e["handlerAdded()"] 534b3014_fb43_b7da_6519_934d27b7ca9d -->|calls| 3c318cdf_c917_da17_c963_7ace79e37c0e style 534b3014_fb43_b7da_6519_934d27b7ca9d fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
transport/src/test/java/io/netty/channel/PendingWriteQueueTest.java lines 92–139
@Test
public void shouldFireChannelWritabilityChangedAfterRemoval() {
final AtomicReference<ChannelHandlerContext> ctxRef = new AtomicReference<ChannelHandlerContext>();
final AtomicReference<PendingWriteQueue> queueRef = new AtomicReference<PendingWriteQueue>();
final ByteBuf msg = Unpooled.copiedBuffer("test", CharsetUtil.US_ASCII);
final EmbeddedChannel channel = new EmbeddedChannel(new ChannelInboundHandlerAdapter() {
@Override
public void handlerAdded(ChannelHandlerContext ctx) {
ctxRef.set(ctx);
queueRef.set(new PendingWriteQueue(ctx));
}
@Override
public void channelWritabilityChanged(ChannelHandlerContext ctx) {
final PendingWriteQueue queue = queueRef.get();
final ByteBuf msg = (ByteBuf) queue.current();
if (msg == null) {
return;
}
assertEquals(1, msg.refCnt());
// This call will trigger another channelWritabilityChanged() event because the number of
// pending bytes will go below the low watermark.
//
// If PendingWriteQueue.remove() did not remove the current entry before triggering
// channelWritabilityChanged() event, we will end up with attempting to remove the same
// element twice, resulting in the double release.
queue.remove();
assertEquals(0, msg.refCnt());
}
});
channel.config().setWriteBufferLowWaterMark(1);
channel.config().setWriteBufferHighWaterMark(3);
final PendingWriteQueue queue = queueRef.get();
// Trigger channelWritabilityChanged() by adding a message that's larger than the high watermark.
queue.add(msg, channel.newPromise());
channel.finish();
assertEquals(0, msg.refCnt());
}
Domain
Subdomains
Source
Frequently Asked Questions
What does shouldFireChannelWritabilityChangedAfterRemoval() do?
shouldFireChannelWritabilityChangedAfterRemoval() is a function in the netty codebase, defined in transport/src/test/java/io/netty/channel/PendingWriteQueueTest.java.
Where is shouldFireChannelWritabilityChangedAfterRemoval() defined?
shouldFireChannelWritabilityChangedAfterRemoval() is defined in transport/src/test/java/io/netty/channel/PendingWriteQueueTest.java at line 92.
What does shouldFireChannelWritabilityChangedAfterRemoval() call?
shouldFireChannelWritabilityChangedAfterRemoval() calls 2 function(s): EmbeddedChannel, handlerAdded.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free