testNonApplicationDataFailureFailsQueuedWrites() — netty Function Reference
Architecture documentation for the testNonApplicationDataFailureFailsQueuedWrites() function in SslHandlerTest.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 2811a98f_8f4d_ac6f_07ea_705d8d6c1727["testNonApplicationDataFailureFailsQueuedWrites()"] adaf7dc7_94e2_152f_ffdb_453fdaa4f25e["SslHandlerTest"] 2811a98f_8f4d_ac6f_07ea_705d8d6c1727 -->|defined in| adaf7dc7_94e2_152f_ffdb_453fdaa4f25e style 2811a98f_8f4d_ac6f_07ea_705d8d6c1727 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
handler/src/test/java/io/netty/handler/ssl/SslHandlerTest.java lines 117–169
@Test
@Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testNonApplicationDataFailureFailsQueuedWrites() throws NoSuchAlgorithmException, InterruptedException {
final CountDownLatch writeLatch = new CountDownLatch(1);
final Queue<ChannelPromise> writesToFail = new ConcurrentLinkedQueue<ChannelPromise>();
SSLEngine engine = newClientModeSSLEngine();
SslHandler handler = new SslHandler(engine) {
@Override
public void write(final ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception {
super.write(ctx, msg, promise);
writeLatch.countDown();
}
};
EmbeddedChannel ch = new EmbeddedChannel(new ChannelDuplexHandler() {
@Override
public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) {
if (msg instanceof ByteBuf) {
if (((ByteBuf) msg).isReadable()) {
writesToFail.add(promise);
} else {
promise.setSuccess();
}
}
ReferenceCountUtil.release(msg);
}
}, handler);
try {
final CountDownLatch writeCauseLatch = new CountDownLatch(1);
final AtomicReference<Throwable> failureRef = new AtomicReference<Throwable>();
ch.write(Unpooled.wrappedBuffer(new byte[]{1})).addListener(future -> {
failureRef.compareAndSet(null, future.cause());
writeCauseLatch.countDown();
});
writeLatch.await();
// Simulate failing the SslHandler non-application writes after there are applications writes queued.
ChannelPromise promiseToFail;
while ((promiseToFail = writesToFail.poll()) != null) {
promiseToFail.setFailure(new RuntimeException("fake exception"));
}
writeCauseLatch.await();
Throwable writeCause = failureRef.get();
assertNotNull(writeCause);
assertInstanceOf(SSLException.class, writeCause);
Throwable cause = handler.handshakeFuture().cause();
assertNotNull(cause);
assertInstanceOf(SSLException.class, cause);
} finally {
assertFalse(ch.finishAndReleaseAll());
}
}
Domain
Subdomains
Source
Frequently Asked Questions
What does testNonApplicationDataFailureFailsQueuedWrites() do?
testNonApplicationDataFailureFailsQueuedWrites() is a function in the netty codebase, defined in handler/src/test/java/io/netty/handler/ssl/SslHandlerTest.java.
Where is testNonApplicationDataFailureFailsQueuedWrites() defined?
testNonApplicationDataFailureFailsQueuedWrites() is defined in handler/src/test/java/io/netty/handler/ssl/SslHandlerTest.java at line 117.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free