Skip to content

Commit 74495fd

Browse files
committed
Add advanced leakdetection for methods introduced by [netty#4842]
Motivation: [netty#4842] introduced 4 new methods but missed to implement advanced leak detection for these. Modifications: Correctly implement advanced leak detection for these methods. Result: Advanced leak detection works for all methods as expected.
1 parent f0f0b69 commit 74495fd

2 files changed

Lines changed: 50 additions & 0 deletions

File tree

buffer/src/main/java/io/netty/buffer/AdvancedLeakAwareByteBuf.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import java.io.OutputStream;
2828
import java.nio.ByteBuffer;
2929
import java.nio.ByteOrder;
30+
import java.nio.channels.FileChannel;
3031
import java.nio.channels.GatheringByteChannel;
3132
import java.nio.channels.ScatteringByteChannel;
3233
import java.nio.charset.Charset;
@@ -843,6 +844,30 @@ public ByteBuf writeLongLE(long value) {
843844
return super.writeLongLE(value);
844845
}
845846

847+
@Override
848+
public int getBytes(int index, FileChannel out, long position, int length) throws IOException {
849+
recordLeakNonRefCountingOperation(leak);
850+
return super.getBytes(index, out, position, length);
851+
}
852+
853+
@Override
854+
public int setBytes(int index, FileChannel in, long position, int length) throws IOException {
855+
recordLeakNonRefCountingOperation(leak);
856+
return super.setBytes(index, in, position, length);
857+
}
858+
859+
@Override
860+
public int readBytes(FileChannel out, long position, int length) throws IOException {
861+
recordLeakNonRefCountingOperation(leak);
862+
return super.readBytes(out, position, length);
863+
}
864+
865+
@Override
866+
public int writeBytes(FileChannel in, long position, int length) throws IOException {
867+
recordLeakNonRefCountingOperation(leak);
868+
return super.writeBytes(in, position, length);
869+
}
870+
846871
@Override
847872
public ByteBuf retain() {
848873
leak.record();

buffer/src/main/java/io/netty/buffer/AdvancedLeakAwareCompositeByteBuf.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import java.io.OutputStream;
2525
import java.nio.ByteBuffer;
2626
import java.nio.ByteOrder;
27+
import java.nio.channels.FileChannel;
2728
import java.nio.channels.GatheringByteChannel;
2829
import java.nio.channels.ScatteringByteChannel;
2930
import java.nio.charset.Charset;
@@ -903,6 +904,30 @@ public CompositeByteBuf consolidate(int cIndex, int numComponents) {
903904
return super.consolidate(cIndex, numComponents);
904905
}
905906

907+
@Override
908+
public int getBytes(int index, FileChannel out, long position, int length) throws IOException {
909+
recordLeakNonRefCountingOperation(leak);
910+
return super.getBytes(index, out, position, length);
911+
}
912+
913+
@Override
914+
public int setBytes(int index, FileChannel in, long position, int length) throws IOException {
915+
recordLeakNonRefCountingOperation(leak);
916+
return super.setBytes(index, in, position, length);
917+
}
918+
919+
@Override
920+
public int readBytes(FileChannel out, long position, int length) throws IOException {
921+
recordLeakNonRefCountingOperation(leak);
922+
return super.readBytes(out, position, length);
923+
}
924+
925+
@Override
926+
public int writeBytes(FileChannel in, long position, int length) throws IOException {
927+
recordLeakNonRefCountingOperation(leak);
928+
return super.writeBytes(in, position, length);
929+
}
930+
906931
@Override
907932
public CompositeByteBuf retain() {
908933
leak.record();

0 commit comments

Comments
 (0)