decode() — netty Function Reference
Architecture documentation for the decode() function in MessageAggregator.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 86b22ee5_e15b_7a0f_a36e_3fe8070d24aa["decode()"] 5eb281df_9169_db16_7477_6d4eba81b483["MessageAggregator"] 86b22ee5_e15b_7a0f_a36e_3fe8070d24aa -->|defined in| 5eb281df_9169_db16_7477_6d4eba81b483 60997f72_c177_04c0_4b40_8ed28c5e39c3["acceptInboundMessage()"] 60997f72_c177_04c0_4b40_8ed28c5e39c3 -->|calls| 86b22ee5_e15b_7a0f_a36e_3fe8070d24aa f9f29fd5_8673_9f39_7bed_e6273210b004["isStartMessage()"] 86b22ee5_e15b_7a0f_a36e_3fe8070d24aa -->|calls| f9f29fd5_8673_9f39_7bed_e6273210b004 f29a941e_367d_75c3_ffe2_b3a61d688b28["closeAfterContinueResponse()"] 86b22ee5_e15b_7a0f_a36e_3fe8070d24aa -->|calls| f29a941e_367d_75c3_ffe2_b3a61d688b28 41e65046_18a8_ef1e_0975_f695e0d00ffc["ignoreContentAfterContinueResponse()"] 86b22ee5_e15b_7a0f_a36e_3fe8070d24aa -->|calls| 41e65046_18a8_ef1e_0975_f695e0d00ffc 1317c594_16a8_5c6c_41af_f6d4ff7ab96d["isContentLengthInvalid()"] 86b22ee5_e15b_7a0f_a36e_3fe8070d24aa -->|calls| 1317c594_16a8_5c6c_41af_f6d4ff7ab96d ec17c0e6_af0a_457f_dbec_d3eaa628396b["invokeHandleOversizedMessage()"] 86b22ee5_e15b_7a0f_a36e_3fe8070d24aa -->|calls| ec17c0e6_af0a_457f_dbec_d3eaa628396b 3a8cd0a9_2df8_6432_15ab_db22b6439f3f["finishAggregation0()"] 86b22ee5_e15b_7a0f_a36e_3fe8070d24aa -->|calls| 3a8cd0a9_2df8_6432_15ab_db22b6439f3f 38667119_38a1_e2f5_325d_357ade65cd56["appendPartialContent()"] 86b22ee5_e15b_7a0f_a36e_3fe8070d24aa -->|calls| 38667119_38a1_e2f5_325d_357ade65cd56 a33e4e9a_5ecb_c862_7f93_67c1ae40c65f["isContentMessage()"] 86b22ee5_e15b_7a0f_a36e_3fe8070d24aa -->|calls| a33e4e9a_5ecb_c862_7f93_67c1ae40c65f 4aed4b36_ccf8_b630_13e2_5d970e81b2a8["aggregate()"] 86b22ee5_e15b_7a0f_a36e_3fe8070d24aa -->|calls| 4aed4b36_ccf8_b630_13e2_5d970e81b2a8 c0941375_911e_6122_f744_1a1d343f1b9a["isLastContentMessage()"] 86b22ee5_e15b_7a0f_a36e_3fe8070d24aa -->|calls| c0941375_911e_6122_f744_1a1d343f1b9a style 86b22ee5_e15b_7a0f_a36e_3fe8070d24aa fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
codec-base/src/main/java/io/netty/handler/codec/MessageAggregator.java lines 205–324
@Override
protected void decode(final ChannelHandlerContext ctx, I msg, List<Object> out) throws Exception {
if (isStartMessage(msg)) {
aggregating = true;
handlingOversizedMessage = false;
if (currentMessage != null) {
currentMessage.release();
currentMessage = null;
throw new MessageAggregationException();
}
@SuppressWarnings("unchecked")
S m = (S) msg;
// Send the continue response if necessary (e.g. 'Expect: 100-continue' header)
// Check before content length. Failing an expectation may result in a different response being sent.
Object continueResponse = newContinueResponse(m, maxContentLength, ctx.pipeline());
if (continueResponse != null) {
// Cache the write listener for reuse.
ChannelFutureListener listener = continueResponseWriteListener;
if (listener == null) {
continueResponseWriteListener = listener = future -> {
if (!future.isSuccess()) {
ctx.fireExceptionCaught(future.cause());
}
};
}
// Make sure to call this before writing, otherwise reference counts may be invalid.
boolean closeAfterWrite = closeAfterContinueResponse(continueResponse);
handlingOversizedMessage = ignoreContentAfterContinueResponse(continueResponse);
final ChannelFuture future = ctx.writeAndFlush(continueResponse).addListener(listener);
if (closeAfterWrite) {
handleIncompleteAggregateDuringClose = false;
future.addListener(ChannelFutureListener.CLOSE);
return;
}
if (handlingOversizedMessage) {
return;
}
} else if (isContentLengthInvalid(m, maxContentLength)) {
// if content length is set, preemptively close if it's too large
invokeHandleOversizedMessage(ctx, m);
return;
}
if (m instanceof DecoderResultProvider && !((DecoderResultProvider) m).decoderResult().isSuccess()) {
O aggregated;
if (m instanceof ByteBufHolder) {
aggregated = beginAggregation(m, ((ByteBufHolder) m).content().retain());
} else {
aggregated = beginAggregation(m, EMPTY_BUFFER);
}
finishAggregation0(aggregated);
out.add(aggregated);
return;
}
// A streamed message - initialize the cumulative buffer, and wait for incoming chunks.
CompositeByteBuf content = ctx.alloc().compositeBuffer(maxCumulationBufferComponents);
if (m instanceof ByteBufHolder) {
appendPartialContent(content, ((ByteBufHolder) m).content());
}
currentMessage = beginAggregation(m, content);
} else if (isContentMessage(msg)) {
if (currentMessage == null) {
// it is possible that a TooLongFrameException was already thrown but we can still discard data
// until the begging of the next request/response.
return;
}
// Merge the received chunk into the content of the current message.
CompositeByteBuf content = (CompositeByteBuf) currentMessage.content();
@SuppressWarnings("unchecked")
final C m = (C) msg;
// Handle oversized message.
if (content.readableBytes() > maxContentLength - m.content().readableBytes()) {
// By convention, full message type extends first message type.
Domain
Subdomains
Calls
Called By
Source
Frequently Asked Questions
What does decode() do?
decode() is a function in the netty codebase, defined in codec-base/src/main/java/io/netty/handler/codec/MessageAggregator.java.
Where is decode() defined?
decode() is defined in codec-base/src/main/java/io/netty/handler/codec/MessageAggregator.java at line 205.
What does decode() call?
decode() calls 10 function(s): aggregate, appendPartialContent, closeAfterContinueResponse, finishAggregation0, ignoreContentAfterContinueResponse, invokeHandleOversizedMessage, isContentLengthInvalid, isContentMessage, and 2 more.
What calls decode()?
decode() is called by 1 function(s): acceptInboundMessage.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free