write() — netty Function Reference
Architecture documentation for the write() function in MessageToMessageEncoder.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 2e6c2add_abce_1e65_fc06_6fd8d0a1f4d5["write()"] 5de88c7e_af22_af85_54c4_7537ccd3bd88["MessageToMessageEncoder"] 2e6c2add_abce_1e65_fc06_6fd8d0a1f4d5 -->|defined in| 5de88c7e_af22_af85_54c4_7537ccd3bd88 68a434ac_b99b_038a_3645_f543bca82280["writeVoidPromise()"] 68a434ac_b99b_038a_3645_f543bca82280 -->|calls| 2e6c2add_abce_1e65_fc06_6fd8d0a1f4d5 859182f4_3b42_644a_4f64_af2ebd8f2c1b["writePromiseCombiner()"] 859182f4_3b42_644a_4f64_af2ebd8f2c1b -->|calls| 2e6c2add_abce_1e65_fc06_6fd8d0a1f4d5 4b14cfce_c60b_3d25_a814_63dd23ee14f7["acceptOutboundMessage()"] 2e6c2add_abce_1e65_fc06_6fd8d0a1f4d5 -->|calls| 4b14cfce_c60b_3d25_a814_63dd23ee14f7 a517d4ee_a59c_55f0_5218_fedc7b1ab3c7["encode()"] 2e6c2add_abce_1e65_fc06_6fd8d0a1f4d5 -->|calls| a517d4ee_a59c_55f0_5218_fedc7b1ab3c7 68a434ac_b99b_038a_3645_f543bca82280["writeVoidPromise()"] 2e6c2add_abce_1e65_fc06_6fd8d0a1f4d5 -->|calls| 68a434ac_b99b_038a_3645_f543bca82280 859182f4_3b42_644a_4f64_af2ebd8f2c1b["writePromiseCombiner()"] 2e6c2add_abce_1e65_fc06_6fd8d0a1f4d5 -->|calls| 859182f4_3b42_644a_4f64_af2ebd8f2c1b style 2e6c2add_abce_1e65_fc06_6fd8d0a1f4d5 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
codec-base/src/main/java/io/netty/handler/codec/MessageToMessageEncoder.java lines 81–128
@Override
public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception {
CodecOutputList out = null;
try {
if (acceptOutboundMessage(msg)) {
out = CodecOutputList.newInstance();
@SuppressWarnings("unchecked")
I cast = (I) msg;
try {
encode(ctx, cast, out);
} catch (Throwable th) {
ReferenceCountUtil.safeRelease(cast);
PlatformDependent.throwException(th);
}
ReferenceCountUtil.release(cast);
if (out.isEmpty()) {
throw new EncoderException(
StringUtil.simpleClassName(this) + " must produce at least one message.");
}
} else {
ctx.write(msg, promise);
}
} catch (EncoderException e) {
throw e;
} catch (Throwable t) {
throw new EncoderException(t);
} finally {
if (out != null) {
try {
final int sizeMinusOne = out.size() - 1;
if (sizeMinusOne == 0) {
ctx.write(out.getUnsafe(0), promise);
} else if (sizeMinusOne > 0) {
// Check if we can use a voidPromise for our extra writes to reduce GC-Pressure
// See https://github.com/netty/netty/issues/2525
if (promise == ctx.voidPromise()) {
writeVoidPromise(ctx, out);
} else {
writePromiseCombiner(ctx, out, promise);
}
}
} finally {
out.recycle();
}
}
}
}
Domain
Subdomains
Called By
Source
Frequently Asked Questions
What does write() do?
write() is a function in the netty codebase, defined in codec-base/src/main/java/io/netty/handler/codec/MessageToMessageEncoder.java.
Where is write() defined?
write() is defined in codec-base/src/main/java/io/netty/handler/codec/MessageToMessageEncoder.java at line 81.
What does write() call?
write() calls 4 function(s): acceptOutboundMessage, encode, writePromiseCombiner, writeVoidPromise.
What calls write()?
write() is called by 2 function(s): writePromiseCombiner, writeVoidPromise.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free