Skip to content

Commit e821d5e

Browse files
committed
core: touch() buffer when detach()ing
Detachable lets a buffer outlive its original lifetime. The new lifetime is application-controlled. If the application fails to read/close the stream, then the leak detector wouldn't make clear what code was responsible for the buffer's lifetime. With this touch, we'll be able to see detach() was called and thus know the application needs debugging. Realized when looking at b/364531464, although I think the issue is unrelated.
1 parent 1dae144 commit e821d5e

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

core/src/main/java/io/grpc/internal/ReadableBuffers.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,7 @@ public ByteBuffer getByteBuffer() {
415415
public InputStream detach() {
416416
ReadableBuffer detachedBuffer = buffer;
417417
buffer = buffer.readBytes(0);
418+
detachedBuffer.touch();
418419
return new BufferInputStream(detachedBuffer);
419420
}
420421

0 commit comments

Comments
 (0)