Record release when enable detailed leak detection

Motivation:
It would be easier to find where is missing release call in several retain release calls on a ByteBuf

Modifications:
Remove final modifier on SimpleLeakAwareByteBuf and SimpleLeakAwareByteBuf release function and override it to record release in AdvancedLeakAwareByteBuf and AdvancedLeakAwareCompositeByteBuf

Result:
Release will be recorded when enable detailed leak detection
This commit is contained in:
louxiu 2017-07-16 15:38:16 +08:00 committed by Norman Maurer
parent f1e14d0cb2
commit 0ad99310f5
4 changed files with 28 additions and 4 deletions

View File

@ -931,6 +931,18 @@ final class AdvancedLeakAwareByteBuf extends SimpleLeakAwareByteBuf {
return super.retain(increment);
}
@Override
public boolean release() {
leak.record();
return super.release();
}
@Override
public boolean release(int decrement) {
leak.record();
return super.release(decrement);
}
@Override
public ByteBuf touch() {
leak.record();

View File

@ -1017,6 +1017,18 @@ final class AdvancedLeakAwareCompositeByteBuf extends SimpleLeakAwareCompositeBy
return super.retain(increment);
}
@Override
public boolean release() {
leak.record();
return super.release();
}
@Override
public boolean release(int decrement) {
leak.record();
return super.release(decrement);
}
@Override
public CompositeByteBuf touch() {
leak.record();

View File

@ -98,7 +98,7 @@ class SimpleLeakAwareByteBuf extends WrappedByteBuf {
}
@Override
public final boolean release() {
public boolean release() {
if (super.release()) {
closeLeak();
return true;
@ -107,7 +107,7 @@ class SimpleLeakAwareByteBuf extends WrappedByteBuf {
}
@Override
public final boolean release(int decrement) {
public boolean release(int decrement) {
if (super.release(decrement)) {
closeLeak();
return true;

View File

@ -31,7 +31,7 @@ class SimpleLeakAwareCompositeByteBuf extends WrappedCompositeByteBuf {
}
@Override
public final boolean release() {
public boolean release() {
// Call unwrap() before just in case that super.release() will change the ByteBuf instance that is returned
// by unwrap().
ByteBuf unwrapped = unwrap();
@ -43,7 +43,7 @@ class SimpleLeakAwareCompositeByteBuf extends WrappedCompositeByteBuf {
}
@Override
public final boolean release(int decrement) {
public boolean release(int decrement) {
// Call unwrap() before just in case that super.release() will change the ByteBuf instance that is returned
// by unwrap().
ByteBuf unwrapped = unwrap();