Permalink
Browse files

Enable a user specify an arbitrary information with ReferenceCounted.…

…touch()

- Related: #2163
- Add ResourceLeakHint to allow a user to provide a meaningful information about the leak when touching it
- DefaultChannelHandlerContext now implements ResourceLeakHint to tell where the message is going.
- Cleaner resource leak report by excluding noisy stack trace elements
  • Loading branch information...
1 parent 3061b15 commit 0f1b1be0aa008d6fc227e3af622d71062227d5ae @trustin trustin committed Jan 29, 2014
Showing with 493 additions and 18 deletions.
  1. +6 −0 buffer/src/main/java/io/netty/buffer/AbstractDerivedByteBuf.java
  2. +6 −1 buffer/src/main/java/io/netty/buffer/AbstractReferenceCountedByteBuf.java
  3. +6 −0 buffer/src/main/java/io/netty/buffer/AdvancedLeakAwareByteBuf.java
  4. +3 −0 buffer/src/main/java/io/netty/buffer/ByteBuf.java
  5. +3 −0 buffer/src/main/java/io/netty/buffer/ByteBufHolder.java
  6. +10 −0 buffer/src/main/java/io/netty/buffer/CompositeByteBuf.java
  7. +6 −0 buffer/src/main/java/io/netty/buffer/DefaultByteBufHolder.java
  8. +5 −0 buffer/src/main/java/io/netty/buffer/EmptyByteBuf.java
  9. +5 −0 buffer/src/main/java/io/netty/buffer/SimpleLeakAwareByteBuf.java
  10. +6 −0 buffer/src/main/java/io/netty/buffer/SwappedByteBuf.java
  11. +5 −0 buffer/src/main/java/io/netty/buffer/UnreleasableByteBuf.java
  12. +6 −0 buffer/src/main/java/io/netty/buffer/WrappedByteBuf.java
  13. +5 −0 codec-http/src/main/java/io/netty/handler/codec/http/ComposedLastHttpContent.java
  14. +6 −0 codec-http/src/main/java/io/netty/handler/codec/http/DefaultFullHttpRequest.java
  15. +6 −0 codec-http/src/main/java/io/netty/handler/codec/http/DefaultFullHttpResponse.java
  16. +6 −0 codec-http/src/main/java/io/netty/handler/codec/http/DefaultHttpContent.java
  17. +6 −0 codec-http/src/main/java/io/netty/handler/codec/http/DefaultLastHttpContent.java
  18. +3 −0 codec-http/src/main/java/io/netty/handler/codec/http/FullHttpMessage.java
  19. +3 −0 codec-http/src/main/java/io/netty/handler/codec/http/FullHttpRequest.java
  20. +3 −0 codec-http/src/main/java/io/netty/handler/codec/http/FullHttpResponse.java
  21. +3 −0 codec-http/src/main/java/io/netty/handler/codec/http/HttpContent.java
  22. +8 −0 codec-http/src/main/java/io/netty/handler/codec/http/LastHttpContent.java
  23. +5 −0 codec-http/src/main/java/io/netty/handler/codec/http/multipart/AbstractDiskHttpData.java
  24. +3 −0 codec-http/src/main/java/io/netty/handler/codec/http/multipart/AbstractHttpData.java
  25. +6 −1 codec-http/src/main/java/io/netty/handler/codec/http/multipart/AbstractMemoryHttpData.java
  26. +3 −0 codec-http/src/main/java/io/netty/handler/codec/http/multipart/Attribute.java
  27. +6 −0 codec-http/src/main/java/io/netty/handler/codec/http/multipart/DiskAttribute.java
  28. +6 −0 codec-http/src/main/java/io/netty/handler/codec/http/multipart/DiskFileUpload.java
  29. +3 −0 codec-http/src/main/java/io/netty/handler/codec/http/multipart/FileUpload.java
  30. +3 −0 codec-http/src/main/java/io/netty/handler/codec/http/multipart/HttpData.java
  31. +6 −0 codec-http/src/main/java/io/netty/handler/codec/http/multipart/HttpPostRequestEncoder.java
  32. +3 −0 codec-http/src/main/java/io/netty/handler/codec/http/multipart/InterfaceHttpData.java
  33. +8 −0 codec-http/src/main/java/io/netty/handler/codec/http/multipart/InternalAttribute.java
  34. +6 −0 codec-http/src/main/java/io/netty/handler/codec/http/multipart/MemoryAttribute.java
  35. +6 −0 codec-http/src/main/java/io/netty/handler/codec/http/multipart/MemoryFileUpload.java
  36. +6 −0 codec-http/src/main/java/io/netty/handler/codec/http/multipart/MixedAttribute.java
  37. +6 −0 codec-http/src/main/java/io/netty/handler/codec/http/multipart/MixedFileUpload.java
  38. +6 −0 codec-http/src/main/java/io/netty/handler/codec/http/websocketx/BinaryWebSocketFrame.java
  39. +6 −0 codec-http/src/main/java/io/netty/handler/codec/http/websocketx/CloseWebSocketFrame.java
  40. +6 −0 codec-http/src/main/java/io/netty/handler/codec/http/websocketx/ContinuationWebSocketFrame.java
  41. +6 −0 codec-http/src/main/java/io/netty/handler/codec/http/websocketx/PingWebSocketFrame.java
  42. +6 −0 codec-http/src/main/java/io/netty/handler/codec/http/websocketx/PongWebSocketFrame.java
  43. +6 −0 codec-http/src/main/java/io/netty/handler/codec/http/websocketx/TextWebSocketFrame.java
  44. +6 −0 codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketFrame.java
  45. +6 −0 codec-http/src/main/java/io/netty/handler/codec/spdy/DefaultSpdyDataFrame.java
  46. +3 −0 codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyDataFrame.java
  47. +6 −0 codec-memcache/src/main/java/io/netty/handler/codec/memcache/DefaultLastMemcacheContent.java
  48. +6 −0 codec-memcache/src/main/java/io/netty/handler/codec/memcache/DefaultMemcacheContent.java
  49. +3 −0 codec-memcache/src/main/java/io/netty/handler/codec/memcache/FullMemcacheMessage.java
  50. +8 −0 codec-memcache/src/main/java/io/netty/handler/codec/memcache/LastMemcacheContent.java
  51. +3 −0 codec-memcache/src/main/java/io/netty/handler/codec/memcache/MemcacheContent.java
  52. +3 −0 codec-memcache/src/main/java/io/netty/handler/codec/memcache/MemcacheMessage.java
  53. +6 −1 ...-memcache/src/main/java/io/netty/handler/codec/memcache/binary/AbstractBinaryMemcacheMessage.java
  54. +3 −0 codec-memcache/src/main/java/io/netty/handler/codec/memcache/binary/BinaryMemcacheMessage.java
  55. +3 −0 codec-memcache/src/main/java/io/netty/handler/codec/memcache/binary/BinaryMemcacheRequest.java
  56. +3 −0 codec-memcache/src/main/java/io/netty/handler/codec/memcache/binary/BinaryMemcacheResponse.java
  57. +6 −0 ...c-memcache/src/main/java/io/netty/handler/codec/memcache/binary/DefaultBinaryMemcacheRequest.java
  58. +6 −0 ...-memcache/src/main/java/io/netty/handler/codec/memcache/binary/DefaultBinaryMemcacheResponse.java
  59. +6 −0 ...mcache/src/main/java/io/netty/handler/codec/memcache/binary/DefaultFullBinaryMemcacheRequest.java
  60. +6 −0 ...cache/src/main/java/io/netty/handler/codec/memcache/binary/DefaultFullBinaryMemcacheResponse.java
  61. +3 −0 codec-memcache/src/main/java/io/netty/handler/codec/memcache/binary/FullBinaryMemcacheRequest.java
  62. +3 −0 codec-memcache/src/main/java/io/netty/handler/codec/memcache/binary/FullBinaryMemcacheResponse.java
  63. +6 −0 codec/src/main/java/io/netty/handler/codec/ReplayingDecoderBuffer.java
  64. +5 −0 common/src/main/java/io/netty/util/AbstractReferenceCounted.java
  65. +13 −0 common/src/main/java/io/netty/util/ReferenceCountUtil.java
  66. +8 −1 common/src/main/java/io/netty/util/ReferenceCounted.java
  67. +7 −1 common/src/main/java/io/netty/util/ResourceLeak.java
  68. +49 −8 common/src/main/java/io/netty/util/ResourceLeakDetector.java
  69. +27 −0 common/src/main/java/io/netty/util/ResourceLeakHint.java
  70. +6 −0 transport-sctp/src/main/java/io/netty/channel/sctp/SctpMessage.java
  71. +6 −0 transport-udt/src/main/java/io/netty/channel/udt/UdtMessage.java
  72. +12 −0 transport/src/main/java/io/netty/channel/AddressedEnvelope.java
  73. +6 −0 transport/src/main/java/io/netty/channel/DefaultAddressedEnvelope.java
  74. +16 −4 transport/src/main/java/io/netty/channel/DefaultChannelHandlerContext.java
  75. +5 −0 transport/src/main/java/io/netty/channel/DefaultFileRegion.java
  76. +3 −0 transport/src/main/java/io/netty/channel/FileRegion.java
  77. +6 −0 transport/src/main/java/io/netty/channel/socket/DatagramPacket.java
  78. +1 −1 transport/src/test/java/io/netty/channel/DefaultChannelPipelineTest.java
@@ -51,6 +51,12 @@ public final ByteBuf touch() {
return this;
}
+ @Override
+ public final ByteBuf touch(Object hint) {
+ unwrap().touch(hint);
+ return this;
+ }
+
@Override
public final boolean release() {
return unwrap().release();
@@ -108,7 +108,12 @@ public ByteBuf retain(int increment) {
}
@Override
- public final ByteBuf touch() {
+ public ByteBuf touch() {
+ return this;
+ }
+
+ @Override
+ public ByteBuf touch(Object hint) {
return this;
}
@@ -722,6 +722,12 @@ public ByteBuf touch() {
return this;
}
+ @Override
+ public ByteBuf touch(Object hint) {
+ leak.record(hint);
+ return this;
+ }
+
@Override
public ByteBuf capacity(int newCapacity) {
leak.record();
@@ -1880,4 +1880,7 @@
@Override
public abstract ByteBuf touch();
+
+ @Override
+ public abstract ByteBuf touch(Object hint);
}
@@ -45,4 +45,7 @@
@Override
ByteBufHolder touch();
+
+ @Override
+ ByteBufHolder touch(Object hint);
}
@@ -1570,6 +1570,16 @@ public CompositeByteBuf retain() {
return (CompositeByteBuf) super.retain();
}
+ @Override
+ public CompositeByteBuf touch() {
+ return (CompositeByteBuf) super.touch();
+ }
+
+ @Override
+ public CompositeByteBuf touch(Object hint) {
+ return (CompositeByteBuf) super.touch(hint);
+ }
+
@Override
public ByteBuffer[] nioBuffers() {
return nioBuffers(readerIndex(), readableBytes());
@@ -74,6 +74,12 @@ public ByteBufHolder touch() {
return this;
}
+ @Override
+ public ByteBufHolder touch(Object hint) {
+ data.touch(hint);
+ return this;
+ }
+
@Override
public boolean release() {
return data.release();
@@ -836,6 +836,11 @@ public ByteBuf touch() {
return this;
}
+ @Override
+ public ByteBuf touch(Object hint) {
+ return this;
+ }
+
@Override
public boolean release() {
return false;
@@ -34,6 +34,11 @@ public ByteBuf touch() {
return this;
}
+ @Override
+ public ByteBuf touch(Object hint) {
+ return this;
+ }
+
@Override
public boolean release() {
boolean deallocated = super.release();
@@ -820,6 +820,12 @@ public ByteBuf touch() {
return this;
}
+ @Override
+ public ByteBuf touch(Object hint) {
+ buf.touch(hint);
+ return this;
+ }
+
@Override
public boolean release() {
return buf.release();
@@ -80,6 +80,11 @@ public ByteBuf touch() {
return this;
}
+ @Override
+ public ByteBuf touch(Object hint) {
+ return this;
+ }
+
@Override
public boolean release() {
return false;
@@ -805,6 +805,12 @@ public ByteBuf touch() {
return this;
}
+ @Override
+ public ByteBuf touch(Object hint) {
+ buf.touch(hint);
+ return this;
+ }
+
@Override
public boolean isReadable(int size) {
return buf.isReadable(size);
@@ -54,6 +54,11 @@ public LastHttpContent touch() {
return this;
}
+ @Override
+ public LastHttpContent touch(Object hint) {
+ return this;
+ }
+
@Override
public LastHttpContent duplicate() {
return copy();
@@ -78,6 +78,12 @@ public FullHttpRequest touch() {
return this;
}
+ @Override
+ public FullHttpRequest touch(Object hint) {
+ content.touch(hint);
+ return this;
+ }
+
@Override
public boolean release() {
return content.release();
@@ -81,6 +81,12 @@ public FullHttpResponse touch() {
return this;
}
+ @Override
+ public FullHttpResponse touch(Object hint) {
+ content.touch(hint);
+ return this;
+ }
+
@Override
public boolean release() {
return content.release();
@@ -73,6 +73,12 @@ public HttpContent touch() {
return this;
}
+ @Override
+ public HttpContent touch(Object hint) {
+ content.touch(hint);
+ return this;
+ }
+
@Override
public boolean release() {
return content.release();
@@ -75,6 +75,12 @@ public LastHttpContent touch() {
return this;
}
+ @Override
+ public LastHttpContent touch(Object hint) {
+ super.touch(hint);
+ return this;
+ }
+
@Override
public HttpHeaders trailingHeaders() {
return trailingHeaders;
@@ -32,6 +32,9 @@
@Override
FullHttpMessage touch();
+ @Override
+ FullHttpMessage touch(Object hint);
+
@Override
FullHttpMessage duplicate();
}
@@ -32,6 +32,9 @@
@Override
FullHttpRequest touch();
+ @Override
+ FullHttpRequest touch(Object hint);
+
@Override
FullHttpRequest duplicate();
@@ -32,6 +32,9 @@
@Override
FullHttpResponse touch();
+ @Override
+ FullHttpResponse touch(Object hint);
+
@Override
FullHttpResponse duplicate();
@@ -41,4 +41,7 @@
@Override
HttpContent touch();
+
+ @Override
+ HttpContent touch(Object hint);
}
@@ -79,6 +79,11 @@ public LastHttpContent touch() {
return this;
}
+ @Override
+ public LastHttpContent touch(Object hint) {
+ return this;
+ }
+
@Override
public boolean release() {
return false;
@@ -109,6 +114,9 @@ public String toString() {
@Override
LastHttpContent touch();
+ @Override
+ LastHttpContent touch(Object hint);
+
@Override
LastHttpContent duplicate();
}
@@ -401,4 +401,9 @@ public File getFile() throws IOException {
public HttpData touch() {
return this;
}
+
+ @Override
+ public HttpData touch(Object hint) {
+ return this;
+ }
}
@@ -133,4 +133,7 @@ public HttpData retain(int increment) {
@Override
public abstract HttpData touch();
+
+ @Override
+ public abstract HttpData touch(Object hint);
}
@@ -260,8 +260,13 @@ public File getFile() throws IOException {
@Override
public HttpData touch() {
+ return touch(null);
+ }
+
+ @Override
+ public HttpData touch(Object hint) {
if (byteBuf != null) {
- byteBuf.touch();
+ byteBuf.touch(hint);
}
return this;
}
@@ -45,4 +45,7 @@
@Override
Attribute touch();
+
+ @Override
+ Attribute touch(Object hint);
}
@@ -198,4 +198,10 @@ public Attribute touch() {
super.touch();
return this;
}
+
+ @Override
+ public Attribute touch(Object hint) {
+ super.touch(hint);
+ return this;
+ }
}
@@ -217,4 +217,10 @@ public FileUpload touch() {
super.touch();
return this;
}
+
+ @Override
+ public FileUpload touch(Object hint) {
+ super.touch(hint);
+ return this;
+ }
}
@@ -70,4 +70,7 @@
@Override
FileUpload touch();
+
+ @Override
+ FileUpload touch(Object hint);
}
@@ -211,4 +211,7 @@
@Override
HttpData touch();
+
+ @Override
+ HttpData touch(Object hint);
}
@@ -1221,6 +1221,12 @@ public FullHttpRequest touch() {
return this;
}
+ @Override
+ public FullHttpRequest touch(Object hint) {
+ content.touch(hint);
+ return this;
+ }
+
@Override
public ByteBuf content() {
return content.content();
@@ -44,4 +44,7 @@
@Override
InterfaceHttpData touch();
+
+ @Override
+ InterfaceHttpData touch(Object hint);
}
@@ -149,4 +149,12 @@ public InterfaceHttpData touch() {
}
return this;
}
+
+ @Override
+ public InterfaceHttpData touch(Object hint) {
+ for (ByteBuf buf: value) {
+ buf.touch(hint);
+ }
+ return this;
+ }
}
@@ -159,4 +159,10 @@ public Attribute touch() {
super.touch();
return this;
}
+
+ @Override
+ public Attribute touch(Object hint) {
+ super.touch(hint);
+ return this;
+ }
}
Oops, something went wrong.

0 comments on commit 0f1b1be

Please sign in to comment.