wrapNonAppData() — netty Function Reference
Architecture documentation for the wrapNonAppData() function in SslHandler.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 5759ad29_b25e_dc08_15d9_5d7a84356f31["wrapNonAppData()"] d8b07a7c_44f8_c4e9_efe8_49bfae7d4af1["SslHandler"] 5759ad29_b25e_dc08_15d9_5d7a84356f31 -->|defined in| d8b07a7c_44f8_c4e9_efe8_49bfae7d4af1 51b61e7d_0f6d_53c7_ed6a_56a55b2ed5a7["unwrap()"] 51b61e7d_0f6d_53c7_ed6a_56a55b2ed5a7 -->|calls| 5759ad29_b25e_dc08_15d9_5d7a84356f31 b58a530d_e555_4c6b_6ad0_658b1ae0022d["handshake()"] b58a530d_e555_4c6b_6ad0_658b1ae0022d -->|calls| 5759ad29_b25e_dc08_15d9_5d7a84356f31 3767fed6_8ef0_e61c_ca65_bd1e0902b8bb["resumeOnEventExecutor()"] 3767fed6_8ef0_e61c_ca65_bd1e0902b8bb -->|calls| 5759ad29_b25e_dc08_15d9_5d7a84356f31 ca3c58ac_45a7_24e9_d74b_140cea69627e["wrap()"] 5759ad29_b25e_dc08_15d9_5d7a84356f31 -->|calls| ca3c58ac_45a7_24e9_d74b_140cea69627e 3c66160e_1a9c_d310_8bcb_1a5c64f633f9["write()"] 5759ad29_b25e_dc08_15d9_5d7a84356f31 -->|calls| 3c66160e_1a9c_d310_8bcb_1a5c64f633f9 1802a64b_a8aa_5b0c_6e8f_ccdfa0cfb2dc["setHandshakeFailureTransportFailure()"] 5759ad29_b25e_dc08_15d9_5d7a84356f31 -->|calls| 1802a64b_a8aa_5b0c_6e8f_ccdfa0cfb2dc 586d9480_c5dd_d8c2_fcc9_bd16fdeca640["setState()"] 5759ad29_b25e_dc08_15d9_5d7a84356f31 -->|calls| 586d9480_c5dd_d8c2_fcc9_bd16fdeca640 412a41a8_6a03_f301_fa41_1d7e9d8ad668["setHandshakeSuccess()"] 5759ad29_b25e_dc08_15d9_5d7a84356f31 -->|calls| 412a41a8_6a03_f301_fa41_1d7e9d8ad668 985b3057_a9f6_8ddd_4409_70c4485507c5["runDelegatedTasks()"] 5759ad29_b25e_dc08_15d9_5d7a84356f31 -->|calls| 985b3057_a9f6_8ddd_4409_70c4485507c5 1e626fd1_be04_3828_22be_f23dbb77f38a["unwrapNonAppData()"] 5759ad29_b25e_dc08_15d9_5d7a84356f31 -->|calls| 1e626fd1_be04_3828_22be_f23dbb77f38a cc9a73ea_cfe9_c66d_c539_4a6802139e47["IllegalStateException()"] 5759ad29_b25e_dc08_15d9_5d7a84356f31 -->|calls| cc9a73ea_cfe9_c66d_c539_4a6802139e47 style 5759ad29_b25e_dc08_15d9_5d7a84356f31 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
handler/src/main/java/io/netty/handler/ssl/SslHandler.java lines 994–1081
private boolean wrapNonAppData(final ChannelHandlerContext ctx, boolean inUnwrap) throws SSLException {
ByteBuf out = null;
ByteBufAllocator alloc = ctx.alloc();
try {
// Only continue to loop if the handler was not removed in the meantime.
// See https://github.com/netty/netty/issues/5860
outer: while (!ctx.isRemoved()) {
if (out == null) {
// As this is called for the handshake we have no real idea how big the buffer needs to be.
// That said 2048 should give us enough room to include everything like ALPN / NPN data.
// If this is not enough we will increase the buffer in wrap(...).
out = allocateOutNetBuf(ctx, 2048, 1);
}
SSLEngineResult result = wrap(alloc, engine, Unpooled.EMPTY_BUFFER, out);
if (result.bytesProduced() > 0) {
ctx.write(out).addListener(future -> {
Throwable cause = future.cause();
if (cause != null) {
setHandshakeFailureTransportFailure(ctx, cause);
}
});
if (inUnwrap) {
setState(STATE_NEEDS_FLUSH);
}
out = null;
}
HandshakeStatus status = result.getHandshakeStatus();
switch (status) {
case FINISHED:
// We may be here because we read data and discovered the remote peer initiated a renegotiation
// and this write is to complete the new handshake. The user may have previously done a
// writeAndFlush which wasn't able to wrap data due to needing the pending handshake, so we
// attempt to wrap application data here if any is pending.
if (setHandshakeSuccess() && inUnwrap && !pendingUnencryptedWrites.isEmpty()) {
wrap(ctx, true);
}
return false;
case NEED_TASK:
if (!runDelegatedTasks(inUnwrap)) {
// We scheduled a task on the delegatingTaskExecutor, so stop processing as we will
// resume once the task completes.
break outer;
}
break;
case NEED_UNWRAP:
if (inUnwrap || unwrapNonAppData(ctx) <= 0) {
// If we asked for a wrap, the engine requested an unwrap, and we are in unwrap there is
// no use in trying to call wrap again because we have already attempted (or will after we
// return) to feed more data to the engine.
return false;
}
break;
case NEED_WRAP:
break;
case NOT_HANDSHAKING:
if (setHandshakeSuccess() && inUnwrap && !pendingUnencryptedWrites.isEmpty()) {
wrap(ctx, true);
}
// Workaround for TLS False Start problem reported at:
// https://github.com/netty/netty/issues/1108#issuecomment-14266970
if (!inUnwrap) {
unwrapNonAppData(ctx);
}
return true;
default:
throw new IllegalStateException("Unknown handshake status: " + result.getHandshakeStatus());
}
// Check if did not produce any bytes and if so break out of the loop, but only if we did not process
// a task as last action. It's fine to not produce any data as part of executing a task.
if (result.bytesProduced() == 0 && status != HandshakeStatus.NEED_TASK) {
break;
}
// It should not consume empty buffers when it is not handshaking
// Fix for Android, where it was encrypting empty buffers even when not handshaking
if (result.bytesConsumed() == 0 && result.getHandshakeStatus() == HandshakeStatus.NOT_HANDSHAKING) {
break;
}
}
Domain
Subdomains
Calls
Source
Frequently Asked Questions
What does wrapNonAppData() do?
wrapNonAppData() is a function in the netty codebase, defined in handler/src/main/java/io/netty/handler/ssl/SslHandler.java.
Where is wrapNonAppData() defined?
wrapNonAppData() is defined in handler/src/main/java/io/netty/handler/ssl/SslHandler.java at line 994.
What does wrapNonAppData() call?
wrapNonAppData() calls 8 function(s): IllegalStateException, runDelegatedTasks, setHandshakeFailureTransportFailure, setHandshakeSuccess, setState, unwrapNonAppData, wrap, write.
What calls wrapNonAppData()?
wrapNonAppData() is called by 3 function(s): handshake, resumeOnEventExecutor, unwrap.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free