testHandshakeTimeout0() — netty Function Reference
Architecture documentation for the testHandshakeTimeout0() function in SslHandlerTest.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD c1c1d42c_fd9b_7848_4e03_4028bbbd5b71["testHandshakeTimeout0()"] adaf7dc7_94e2_152f_ffdb_453fdaa4f25e["SslHandlerTest"] c1c1d42c_fd9b_7848_4e03_4028bbbd5b71 -->|defined in| adaf7dc7_94e2_152f_ffdb_453fdaa4f25e f376cf6c_03b1_bf57_ae67_5f2c065c58dd["testHandshakeTimeoutFlushStartsHandshake()"] f376cf6c_03b1_bf57_ae67_5f2c065c58dd -->|calls| c1c1d42c_fd9b_7848_4e03_4028bbbd5b71 770f07eb_cc14_aecc_0487_1204a995bb75["testHandshakeTimeoutStartTLS()"] 770f07eb_cc14_aecc_0487_1204a995bb75 -->|calls| c1c1d42c_fd9b_7848_4e03_4028bbbd5b71 style c1c1d42c_fd9b_7848_4e03_4028bbbd5b71 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
handler/src/test/java/io/netty/handler/ssl/SslHandlerTest.java lines 917–974
private static void testHandshakeTimeout0(final boolean startTls) throws Exception {
final SslContext sslClientCtx = SslContextBuilder.forClient()
.startTls(true)
.trustManager(InsecureTrustManagerFactory.INSTANCE)
.sslProvider(SslProvider.JDK).build();
EventLoopGroup group = new MultiThreadIoEventLoopGroup(NioIoHandler.newFactory());
Channel sc = null;
Channel cc = null;
final SslHandler sslHandler = sslClientCtx.newHandler(UnpooledByteBufAllocator.DEFAULT);
sslHandler.setHandshakeTimeout(500, TimeUnit.MILLISECONDS);
try {
sc = new ServerBootstrap()
.group(group)
.channel(NioServerSocketChannel.class)
.childHandler(new ChannelInboundHandlerAdapter())
.bind(new InetSocketAddress(0)).syncUninterruptibly().channel();
ChannelFuture future = new Bootstrap()
.group(group)
.channel(NioSocketChannel.class)
.handler(new ChannelInitializer<Channel>() {
@Override
protected void initChannel(Channel ch) throws Exception {
ch.pipeline().addLast(sslHandler);
if (startTls) {
ch.pipeline().addLast(new ChannelInboundHandlerAdapter() {
@Override
public void channelActive(ChannelHandlerContext ctx) throws Exception {
ctx.writeAndFlush(wrappedBuffer(new byte[] { 1, 2, 3, 4 }));
}
});
}
}
}).connect(sc.localAddress());
if (!startTls) {
future.addListener((ChannelFutureListener) future1 -> {
// Write something to trigger the handshake before fireChannelActive is called.
future1.channel().writeAndFlush(wrappedBuffer(new byte [] { 1, 2, 3, 4 }));
});
}
cc = future.syncUninterruptibly().channel();
Throwable cause = sslHandler.handshakeFuture().await().cause();
assertInstanceOf(SSLException.class, cause);
assertThat(cause.getMessage()).contains("timed out");
} finally {
if (cc != null) {
cc.close().syncUninterruptibly();
}
if (sc != null) {
sc.close().syncUninterruptibly();
}
group.shutdownGracefully();
ReferenceCountUtil.release(sslClientCtx);
}
}
Domain
Subdomains
Source
Frequently Asked Questions
What does testHandshakeTimeout0() do?
testHandshakeTimeout0() is a function in the netty codebase, defined in handler/src/test/java/io/netty/handler/ssl/SslHandlerTest.java.
Where is testHandshakeTimeout0() defined?
testHandshakeTimeout0() is defined in handler/src/test/java/io/netty/handler/ssl/SslHandlerTest.java at line 917.
What calls testHandshakeTimeout0()?
testHandshakeTimeout0() is called by 2 function(s): testHandshakeTimeoutFlushStartsHandshake, testHandshakeTimeoutStartTLS.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free