AbstractPooledDerivedByteBuf Class — netty Architecture
Architecture documentation for the AbstractPooledDerivedByteBuf class in AbstractPooledDerivedByteBuf.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 71f0dee8_a776_7a4e_70f9_33ece338c7c8["AbstractPooledDerivedByteBuf"] cdd4ec24_c048_f96a_9a21_1774c004b2a8["AbstractPooledDerivedByteBuf.java"] 71f0dee8_a776_7a4e_70f9_33ece338c7c8 -->|defined in| cdd4ec24_c048_f96a_9a21_1774c004b2a8 0f82243d_db94_82d4_326a_2d54fd7793ef["AbstractPooledDerivedByteBuf()"] 71f0dee8_a776_7a4e_70f9_33ece338c7c8 -->|method| 0f82243d_db94_82d4_326a_2d54fd7793ef ce7ee1c0_be9e_4bba_ce97_27fea1ceb9cc["parent()"] 71f0dee8_a776_7a4e_70f9_33ece338c7c8 -->|method| ce7ee1c0_be9e_4bba_ce97_27fea1ceb9cc 8f4d913c_5836_98b6_8746_34c42ee79bef["AbstractByteBuf()"] 71f0dee8_a776_7a4e_70f9_33ece338c7c8 -->|method| 8f4d913c_5836_98b6_8746_34c42ee79bef 3c5ed547_bedb_946f_4195_5c59f61fbaa2["U()"] 71f0dee8_a776_7a4e_70f9_33ece338c7c8 -->|method| 3c5ed547_bedb_946f_4195_5c59f61fbaa2 30b54926_0478_2b0c_6b71_8d6acf5db7f0["deallocate()"] 71f0dee8_a776_7a4e_70f9_33ece338c7c8 -->|method| 30b54926_0478_2b0c_6b71_8d6acf5db7f0 0fb199fc_9a3f_d3f0_227b_b3589ef833d9["ByteBufAllocator()"] 71f0dee8_a776_7a4e_70f9_33ece338c7c8 -->|method| 0fb199fc_9a3f_d3f0_227b_b3589ef833d9 bcb9221c_2251_ca2d_fab2_603fc0d68b45["ByteOrder()"] 71f0dee8_a776_7a4e_70f9_33ece338c7c8 -->|method| bcb9221c_2251_ca2d_fab2_603fc0d68b45 c7450ceb_7123_f3af_f45d_04c2fa8972a7["isReadOnly()"] 71f0dee8_a776_7a4e_70f9_33ece338c7c8 -->|method| c7450ceb_7123_f3af_f45d_04c2fa8972a7 51cec420_ff97_d043_478f_2321b307fb3a["isDirect()"] 71f0dee8_a776_7a4e_70f9_33ece338c7c8 -->|method| 51cec420_ff97_d043_478f_2321b307fb3a 7d6abefe_4448_cc9d_ecab_720a5be33060["hasArray()"] 71f0dee8_a776_7a4e_70f9_33ece338c7c8 -->|method| 7d6abefe_4448_cc9d_ecab_720a5be33060 ee87599c_537c_e3ab_4335_04d360154f42["array()"] 71f0dee8_a776_7a4e_70f9_33ece338c7c8 -->|method| ee87599c_537c_e3ab_4335_04d360154f42 8fe308db_01c1_a2fa_7ec0_5b5aed8ee520["hasMemoryAddress()"] 71f0dee8_a776_7a4e_70f9_33ece338c7c8 -->|method| 8fe308db_01c1_a2fa_7ec0_5b5aed8ee520 02dda212_7afc_d015_2ba1_6ca70b8dbdf5["isContiguous()"] 71f0dee8_a776_7a4e_70f9_33ece338c7c8 -->|method| 02dda212_7afc_d015_2ba1_6ca70b8dbdf5
Relationship Graph
Source Code
buffer/src/main/java/io/netty/buffer/AbstractPooledDerivedByteBuf.java lines 29–330
abstract class AbstractPooledDerivedByteBuf extends AbstractReferenceCountedByteBuf {
private final EnhancedHandle<AbstractPooledDerivedByteBuf> recyclerHandle;
private AbstractByteBuf rootParent;
/**
* Deallocations of a pooled derived buffer should always propagate through the entire chain of derived buffers.
* This is because each pooled derived buffer maintains its own reference count and we should respect each one.
* If deallocations cause a release of the "root parent" then we may prematurely release the underlying
* content before all the derived buffers have been released.
*/
private ByteBuf parent;
@SuppressWarnings("unchecked")
AbstractPooledDerivedByteBuf(Handle<? extends AbstractPooledDerivedByteBuf> recyclerHandle) {
super(0);
this.recyclerHandle = (EnhancedHandle<AbstractPooledDerivedByteBuf>) recyclerHandle;
}
// Called from within SimpleLeakAwareByteBuf and AdvancedLeakAwareByteBuf.
final void parent(ByteBuf newParent) {
assert newParent instanceof SimpleLeakAwareByteBuf;
parent = newParent;
}
@Override
public final AbstractByteBuf unwrap() {
AbstractByteBuf rootParent = this.rootParent;
if (rootParent == null) {
throw new IllegalReferenceCountException();
}
return rootParent;
}
final <U extends AbstractPooledDerivedByteBuf> U init(
AbstractByteBuf unwrapped, ByteBuf wrapped, int readerIndex, int writerIndex, int maxCapacity) {
wrapped.retain(); // Retain up front to ensure the parent is accessible before doing more work.
parent = wrapped;
rootParent = unwrapped;
try {
maxCapacity(maxCapacity);
setIndex0(readerIndex, writerIndex); // It is assumed the bounds checking is done by the caller.
resetRefCnt();
@SuppressWarnings("unchecked")
final U castThis = (U) this;
wrapped = null;
return castThis;
} finally {
if (wrapped != null) {
parent = rootParent = null;
wrapped.release();
}
}
}
@Override
protected final void deallocate() {
// We need to first store a reference to the parent before recycle this instance. This is needed as
// otherwise it is possible that the same AbstractPooledDerivedByteBuf is again obtained and init(...) is
// called before we actually have a chance to call release(). This leads to call release() on the wrong parent.
ByteBuf parent = this.parent;
// Remove references to parent and root so that they can be GCed for leak detection [netty/netty#14247]
this.parent = this.rootParent = null;
recyclerHandle.unguardedRecycle(this);
parent.release();
}
@Override
public final ByteBufAllocator alloc() {
return unwrap().alloc();
}
@Override
@Deprecated
public final ByteOrder order() {
return unwrap().order();
}
@Override
public boolean isReadOnly() {
Source
Frequently Asked Questions
What is the AbstractPooledDerivedByteBuf class?
AbstractPooledDerivedByteBuf is a class in the netty codebase, defined in buffer/src/main/java/io/netty/buffer/AbstractPooledDerivedByteBuf.java.
Where is AbstractPooledDerivedByteBuf defined?
AbstractPooledDerivedByteBuf is defined in buffer/src/main/java/io/netty/buffer/AbstractPooledDerivedByteBuf.java at line 29.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free