Repository: netty/netty
Issue: ResourceLeakException in CR7
Labels: defect

During our tests with our benchmark, we saw a Leak which according to us and norman did not make sense.

Test-Case can be found at https://github.com/wasted/netty-websocket-bench

Output from Server:

fbettag@committers:~/netty-bench$ ./sbt 'run-main io.wasted.netty.websocket.bench.Server'
[info] Loading project definition from /home/fbettag/netty-bench/project
[info] Set current project to netty-bench (in build file:/home/fbettag/netty-bench/)
[info] Running io.wasted.netty.websocket.bench.Server 
22:19:23.818 DEBUG i.n.u.i.l.InternalLoggerFactory - Using SLF4J as the default logging framework
22:19:23.823 DEBUG i.n.c.MultithreadEventLoopGroup - io.netty.eventLoopThreads: 12
22:19:23.835 DEBUG i.n.util.internal.PlatformDependent - UID: 1001
22:19:23.835 DEBUG i.n.util.internal.PlatformDependent - Java version: 7
22:19:23.838 DEBUG i.n.util.internal.PlatformDependent0 - java.nio.ByteBuffer.cleaner: available
22:19:23.839 DEBUG i.n.util.internal.PlatformDependent0 - java.nio.Buffer.address: available
22:19:23.839 DEBUG i.n.util.internal.PlatformDependent0 - sun.misc.Unsafe.theUnsafe: available
22:19:23.839 DEBUG i.n.util.internal.PlatformDependent0 - sun.misc.Unsafe.copyMemory: available
22:19:23.839 DEBUG i.n.util.internal.PlatformDependent0 - java.nio.Bits.unaligned: true
22:19:23.840 DEBUG i.n.util.internal.PlatformDependent - sun.misc.Unsafe: available
22:19:23.967 DEBUG i.n.util.internal.PlatformDependent - Javassist: available
22:19:23.967 DEBUG i.n.util.internal.PlatformDependent - io.netty.noPreferDirect: false
22:19:24.088 DEBUG i.n.buffer.PooledByteBufAllocator - io.netty.allocator.numHeapArenas: 6
22:19:24.088 DEBUG i.n.buffer.PooledByteBufAllocator - io.netty.allocator.numDirectArenas: 6
22:19:24.088 DEBUG i.n.buffer.PooledByteBufAllocator - io.netty.allocator.pageSize: 8192
22:19:24.088 DEBUG i.n.buffer.PooledByteBufAllocator - io.netty.allocator.maxOrder: 11
22:19:24.088 DEBUG i.n.buffer.PooledByteBufAllocator - io.netty.allocator.chunkSize: 16777216
22:19:24.104 DEBUG io.netty.util.NetUtil - Loopback interface: lo
22:19:24.104 DEBUG io.netty.util.NetUtil - Loopback address: /0:0:0:0:0:0:0:1%1 (primary)
22:19:24.104 DEBUG io.netty.util.NetUtil - Loopback address: /127.0.0.1
22:19:24.104 DEBUG io.netty.util.NetUtil - /proc/sys/net/core/somaxconn: 128
22:19:24.129 DEBUG i.n.u.i.JavassistTypeParameterMatcherGenerator - Generated: io.netty.util.internal.**matchers**.io.netty.channel.ChannelMatcher
22:19:24.141 INFO  Server$ - Listening on 0.0.0.0:5555
22:19:24.142 INFO  Server$ - Ready
22:19:24.147 DEBUG io.netty.util.ResourceLeakDetector - io.netty.noResourceLeakDetection: false
22:19:25.200 INFO  Server$ - -- Stats -- connected: 0
22:19:26.294 INFO  Server$ - -- Stats -- connected: 0
22:19:27.394 INFO  Server$ - -- Stats -- connected: 0
22:19:28.395 INFO  Server$ - -- Stats -- connected: 0
22:19:29.395 INFO  Server$ - -- Stats -- connected: 0
22:19:30.495 INFO  Server$ - -- Stats -- connected: 0
22:19:31.168 DEBUG i.n.u.i.JavassistTypeParameterMatcherGenerator - Generated: io.netty.util.internal.**matchers**.io.netty.handler.codec.http.HttpObjectMatcher
22:19:31.398 DEBUG i.n.u.i.JavassistTypeParameterMatcherGenerator - Generated: io.netty.util.internal.**matchers**.io.netty.handler.codec.http.websocketx.WebSocketFrameMatcher
22:19:31.594 INFO  Server$ - -- Stats -- connected: 382
22:19:32.594 INFO  Server$ - -- Stats -- connected: 1629
22:19:32.887 WARN  io.netty.util.ResourceLeakDetector - LEAK: ByteBuf was GC'd before being released correctly.
io.netty.util.ResourceLeakException: io.netty.buffer.DefaultCompositeByteBuf@7572e7e5
  at io.netty.util.ResourceLeakDetector$DefaultResourceLeak.<init>(ResourceLeakDetector.java:158) ~[netty-all-4.0.0.CR7.jar:na]
    at io.netty.util.ResourceLeakDetector.open(ResourceLeakDetector.java:103) ~[netty-all-4.0.0.CR7.jar:na]
    at io.netty.buffer.DefaultCompositeByteBuf.<init>(DefaultCompositeByteBuf.java:60) ~[netty-all-4.0.0.CR7.jar:na]
    at io.netty.buffer.Unpooled.compositeBuffer(Unpooled.java:353) ~[netty-all-4.0.0.CR7.jar:na]
    at io.netty.handler.codec.http.HttpObjectAggregator.decode(HttpObjectAggregator.java:137) ~[netty-all-4.0.0.CR7.jar:na]
    at io.netty.handler.codec.http.HttpObjectAggregator.decode(HttpObjectAggregator.java:49) ~[netty-all-4.0.0.CR7.jar:na]
    at io.netty.handler.codec.MessageToMessageDecoder.messageReceived(MessageToMessageDecoder.java:82) ~[netty-all-4.0.0.CR7.jar:na]
    at io.netty.channel.DefaultChannelHandlerContext.invokeMessageReceived(DefaultChannelHandlerContext.java:379) [netty-all-4.0.0.CR7.jar:na]
    at io.netty.channel.DefaultChannelHandlerContext.fireMessageReceived(DefaultChannelHandlerContext.java:364) [netty-all-4.0.0.CR7.jar:na]
    at io.netty.handler.codec.ByteToMessageDecoder.messageReceived(ByteToMessageDecoder.java:187) [netty-all-4.0.0.CR7.jar:na]
    at io.netty.channel.DefaultChannelHandlerContext.invokeMessageReceived(DefaultChannelHandlerContext.java:379) [netty-all-4.0.0.CR7.jar:na]
    at io.netty.channel.DefaultChannelHandlerContext.fireMessageReceived(DefaultChannelHandlerContext.java:364) [netty-all-4.0.0.CR7.jar:na]
    at io.netty.channel.DefaultChannelPipeline.fireMessageReceived(DefaultChannelPipeline.java:786) [netty-all-4.0.0.CR7.jar:na]
    at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:120) [netty-all-4.0.0.CR7.jar:na]
    at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:489) [netty-all-4.0.0.CR7.jar:na]
    at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:464) [netty-all-4.0.0.CR7.jar:na]
    at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:358) [netty-all-4.0.0.CR7.jar:na]
    at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:101) [netty-all-4.0.0.CR7.jar:na]
    at java.lang.Thread.run(Thread.java:722) [na:1.7.0_03]
22:19:33.694 INFO  Server$ - -- Stats -- connected: 3293
22:19:34.794 INFO  Server$ - -- Stats -- connected: 4434
22:19:35.895 INFO  Server$ - -- Stats -- connected: 4434
22:19:36.995 INFO  Server$ - -- Stats -- connected: 4496
22:19:38.094 INFO  Server$ - -- Stats -- connected: 6172
22:19:39.095 INFO  Server$ - -- Stats -- connected: 8256
22:19:40.195 INFO  Server$ - -- Stats -- connected: 10637
22:19:41.328 INFO  Server$ - -- Stats -- connected: 13811
22:19:42.394 INFO  Server$ - -- Stats -- connected: 14053
22:19:43.494 INFO  Server$ - -- Stats -- connected: 14169
22:19:44.594 INFO  Server$ - -- Stats -- connected: 15114
22:19:45.695 INFO  Server$ - -- Stats -- connected: 15116
22:19:46.795 INFO  Server$ - -- Stats -- connected: 15116
22:19:47.895 INFO  Server$ - -- Stats -- connected: 16018
22:19:48.995 INFO  Server$ - -- Stats -- connected: 16020
22:19:50.095 INFO  Server$ - -- Stats -- connected: 16020
22:19:51.194 INFO  Server$ - -- Stats -- connected: 17850
22:19:52.195 INFO  Server$ - -- Stats -- connected: 18120
22:19:53.294 INFO  Server$ - -- Stats -- connected: 18145
22:19:54.395 INFO  Server$ - -- Stats -- connected: 18752
22:19:55.495 INFO  Server$ - -- Stats -- connected: 20156
22:19:56.595 INFO  Server$ - -- Stats -- connected: 20174
22:19:57.695 INFO  Server$ - -- Stats -- connected: 20198
22:19:58.794 INFO  Server$ - -- Stats -- connected: 23409
22:19:59.894 INFO  Server$ - -- Stats -- connected: 26831
22:20:00.894 INFO  Server$ - -- Stats -- connected: 29504
22:20:01.994 INFO  Server$ - -- Stats -- connected: 30593
22:20:03.094 INFO  Server$ - -- Stats -- connected: 30735
22:20:04.194 INFO  Server$ - -- Stats -- connected: 31655
22:20:05.294 INFO  Server$ - -- Stats -- connected: 32179
22:20:06.395 INFO  Server$ - -- Stats -- connected: 32322
22:20:07.494 INFO  Server$ - -- Stats -- connected: 32612
22:20:08.594 INFO  Server$ - -- Stats -- connected: 32619
22:20:09.595 INFO  Server$ - -- Stats -- connected: 32639
22:20:10.695 INFO  Server$ - -- Stats -- connected: 33241
22:20:11.794 INFO  Server$ - -- Stats -- connected: 33250
22:20:12.894 INFO  Server$ - -- Stats -- connected: 33273
22:20:13.994 INFO  Server$ - -- Stats -- connected: 34017
22:20:15.094 INFO  Server$ - -- Stats -- connected: 34160
22:20:16.194 INFO  Server$ - -- Stats -- connected: 34303
22:20:17.195 INFO  Server$ - -- Stats -- connected: 34696
22:20:18.295 INFO  Server$ - -- Stats -- connected: 34712
22:20:19.395 INFO  Server$ - -- Stats -- connected: 34735
22:20:20.395 INFO  Server$ - -- Stats -- connected: 35236
22:20:21.495 INFO  Server$ - -- Stats -- connected: 35378
22:20:22.595 INFO  Server$ - -- Stats -- connected: 35716
22:20:23.694 INFO  Server$ - -- Stats -- connected: 37473
22:20:24.694 INFO  Server$ - -- Stats -- connected: 37494
22:20:25.794 INFO  Server$ - -- Stats -- connected: 37908
22:20:26.894 INFO  Server$ - -- Stats -- connected: 38825
22:20:27.994 INFO  Server$ - -- Stats -- connected: 38848
22:20:29.094 INFO  Server$ - -- Stats -- connected: 39202
22:20:30.194 INFO  Server$ - -- Stats -- connected: 39346
22:20:31.295 INFO  Server$ - -- Stats -- connected: 39489
22:20:32.395 INFO  Server$ - -- Stats -- connected: 39890
22:20:33.495 INFO  Server$ - -- Stats -- connected: 40032
22:20:34.594 INFO  Server$ - -- Stats -- connected: 40176
22:20:35.694 INFO  Server$ - -- Stats -- connected: 40589
22:20:36.695 INFO  Server$ - -- Stats -- connected: 40721
22:20:37.795 INFO  Server$ - -- Stats -- connected: 40865
22:20:38.895 INFO  Server$ - -- Stats -- connected: 41689
22:20:39.995 INFO  Server$ - -- Stats -- connected: 41712
22:20:41.094 INFO  Server$ - -- Stats -- connected: 41734
22:20:42.194 INFO  Server$ - -- Stats -- connected: 42118
22:20:43.194 INFO  Server$ - -- Stats -- connected: 42249
22:20:44.294 INFO  Server$ - -- Stats -- connected: 42477
22:20:45.394 INFO  Server$ - -- Stats -- connected: 42778
22:20:46.494 INFO  Server$ - -- Stats -- connected: 42923
22:20:47.595 INFO  Server$ - -- Stats -- connected: 43975
22:20:48.695 INFO  Server$ - -- Stats -- connected: 43983
22:20:49.794 INFO  Server$ - -- Stats -- connected: 44006
22:20:50.795 INFO  Server$ - -- Stats -- connected: 44377
22:20:51.894 INFO  Server$ - -- Stats -- connected: 44521
22:20:52.895 INFO  Server$ - -- Stats -- connected: 44649
22:20:53.995 INFO  Server$ - -- Stats -- connected: 45068
22:20:55.095 INFO  Server$ - -- Stats -- connected: 45213
22:20:56.195 INFO  Server$ - -- Stats -- connected: 45360
22:20:57.295 INFO  Server$ - -- Stats -- connected: 45756
22:20:58.394 INFO  Server$ - -- Stats -- connected: 45900
22:20:59.395 INFO  Server$ - -- Stats -- connected: 46033
22:21:00.494 INFO  Server$ - -- Stats -- connected: 48850
22:21:01.594 INFO  Server$ - -- Stats -- connected: 51145
22:21:02.694 INFO  Server$ - -- Stats -- connected: 51674
22:21:03.794 INFO  Server$ - -- Stats -- connected: 52088
22:21:04.895 INFO  Server$ - -- Stats -- connected: 52111
22:21:06.027 INFO  Server$ - -- Stats -- connected: 53118
22:21:07.094 INFO  Server$ - -- Stats -- connected: 57462
22:21:08.094 INFO  Server$ - -- Stats -- connected: 57595
22:21:09.194 INFO  Server$ - -- Stats -- connected: 57740
22:21:10.295 INFO  Server$ - -- Stats -- connected: 57887
22:21:11.395 INFO  Server$ - -- Stats -- connected: 58033
22:21:12.494 INFO  Server$ - -- Stats -- connected: 58178
22:21:13.595 INFO  Server$ - -- Stats -- connected: 58322
22:21:14.695 INFO  Server$ - -- Stats -- connected: 58468
22:21:15.795 INFO  Server$ - -- Stats -- connected: 58614
22:21:16.895 INFO  Server$ - -- Stats -- connected: 58759
22:21:17.995 INFO  Server$ - -- Stats -- connected: 58906
22:21:19.095 INFO  Server$ - -- Stats -- connected: 59053
22:21:20.195 INFO  Server$ - -- Stats -- connected: 59199
22:21:21.294 INFO  Server$ - -- Stats -- connected: 59345
22:21:22.394 INFO  Server$ - -- Stats -- connected: 59487
22:21:23.494 INFO  Server$ - -- Stats -- connected: 59634
22:21:24.594 INFO  Server$ - -- Stats -- connected: 59780
22:21:25.694 INFO  Server$ - -- Stats -- connected: 59927
22:21:26.794 INFO  Server$ - -- Stats -- connected: 60072
22:21:27.894 INFO  Server$ - -- Stats -- connected: 60219
22:21:28.994 INFO  Server$ - -- Stats -- connected: 60366
22:21:30.095 INFO  Server$ - -- Stats -- connected: 60512
22:21:31.195 INFO  Server$ - -- Stats -- connected: 60658
22:21:32.295 INFO  Server$ - -- Stats -- connected: 60801
22:21:33.395 INFO  Server$ - -- Stats -- connected: 60948
22:21:34.495 INFO  Server$ - -- Stats -- connected: 61095
22:21:35.594 INFO  Server$ - -- Stats -- connected: 61241
22:21:36.595 INFO  Server$ - -- Stats -- connected: 61375
22:21:37.694 INFO  Server$ - -- Stats -- connected: 61521
22:21:38.794 INFO  Server$ - -- Stats -- connected: 61667
22:21:39.894 INFO  Server$ - -- Stats -- connected: 61814
22:21:40.994 INFO  Server$ - -- Stats -- connected: 61958
22:21:42.095 INFO  Server$ - -- Stats -- connected: 62105
22:21:43.195 INFO  Server$ - -- Stats -- connected: 62252
22:21:44.294 INFO  Server$ - -- Stats -- connected: 62399
22:21:45.395 INFO  Server$ - -- Stats -- connected: 62547
22:21:46.495 INFO  Server$ - -- Stats -- connected: 62696
22:21:47.595 INFO  Server$ - -- Stats -- connected: 62844
22:21:48.695 INFO  Server$ - -- Stats -- connected: 62993
22:21:49.794 INFO  Server$ - -- Stats -- connected: 63137
22:21:50.795 INFO  Server$ - -- Stats -- connected: 63272
22:21:51.895 INFO  Server$ - -- Stats -- connected: 63421
22:21:52.995 INFO  Server$ - -- Stats -- connected: 63569
22:21:54.095 INFO  Server$ - -- Stats -- connected: 63718
22:21:55.194 INFO  Server$ - -- Stats -- connected: 63866
22:21:56.195 INFO  Server$ - -- Stats -- connected: 64001
22:21:57.294 INFO  Server$ - -- Stats -- connected: 64149
22:21:58.295 INFO  Server$ - -- Stats -- connected: 64285
22:21:59.395 INFO  Server$ - -- Stats -- connected: 64429
22:22:00.494 INFO  Server$ - -- Stats -- connected: 64579
22:22:01.495 INFO  Server$ - -- Stats -- connected: 64715
22:22:02.594 INFO  Server$ - -- Stats -- connected: 64863
22:22:03.595 INFO  Server$ - -- Stats -- connected: 64997
22:22:04.695 INFO  Server$ - -- Stats -- connected: 65146
22:22:05.794 INFO  Server$ - -- Stats -- connected: 65296
22:22:06.894 INFO  Server$ - -- Stats -- connected: 65445
22:22:07.994 INFO  Server$ - -- Stats -- connected: 65594
22:22:09.095 INFO  Server$ - -- Stats -- connected: 65738
22:22:10.195 INFO  Server$ - -- Stats -- connected: 65887
22:22:11.294 INFO  Server$ - -- Stats -- connected: 66036
22:22:12.295 INFO  Server$ - -- Stats -- connected: 66172
22:22:13.395 INFO  Server$ - -- Stats -- connected: 66320
22:22:14.494 INFO  Server$ - -- Stats -- connected: 66470
22:22:15.495 INFO  Server$ - -- Stats -- connected: 66606
22:22:16.594 INFO  Server$ - -- Stats -- connected: 66756
22:22:17.694 INFO  Server$ - -- Stats -- connected: 66901
22:22:18.794 INFO  Server$ - -- Stats -- connected: 67051
22:22:19.894 INFO  Server$ - -- Stats -- connected: 67200
22:22:20.994 INFO  Server$ - -- Stats -- connected: 67350
22:22:22.095 INFO  Server$ - -- Stats -- connected: 67499
22:22:23.195 INFO  Server$ - -- Stats -- connected: 67648
22:22:24.294 INFO  Server$ - -- Stats -- connected: 67799
22:22:25.394 INFO  Server$ - -- Stats -- connected: 67948
22:22:26.495 INFO  Server$ - -- Stats -- connected: 68097
22:22:27.595 INFO  Server$ - -- Stats -- connected: 68243
22:22:28.695 INFO  Server$ - -- Stats -- connected: 68393
22:22:29.795 INFO  Server$ - -- Stats -- connected: 68542
22:22:30.795 INFO  Server$ - -- Stats -- connected: 68679
22:22:31.894 INFO  Server$ - -- Stats -- connected: 68829
22:22:32.895 INFO  Server$ - -- Stats -- connected: 68964
22:22:33.994 INFO  Server$ - -- Stats -- connected: 69114
22:22:34.995 INFO  Server$ - -- Stats -- connected: 69251
22:22:36.095 INFO  Server$ - -- Stats -- connected: 69398
22:22:37.195 INFO  Server$ - -- Stats -- connected: 69546
22:22:38.295 INFO  Server$ - -- Stats -- connected: 69694
22:22:39.395 INFO  Server$ - -- Stats -- connected: 69844
22:22:40.494 INFO  Server$ - -- Stats -- connected: 69994
22:22:41.594 INFO  Server$ - -- Stats -- connected: 70142
22:22:42.694 INFO  Server$ - -- Stats -- connected: 70292
22:22:43.794 INFO  Server$ - -- Stats -- connected: 70441
22:22:44.895 INFO  Server$ - -- Stats -- connected: 70591
22:22:45.995 INFO  Server$ - -- Stats -- connected: 70732
22:22:47.095 INFO  Server$ - -- Stats -- connected: 70874
22:22:48.195 INFO  Server$ - -- Stats -- connected: 71023
22:22:49.295 INFO  Server$ - -- Stats -- connected: 71172
22:22:50.395 INFO  Server$ - -- Stats -- connected: 71322
22:22:51.495 INFO  Server$ - -- Stats -- connected: 71472
22:22:52.595 INFO  Server$ - -- Stats -- connected: 71621
22:22:53.695 INFO  Server$ - -- Stats -- connected: 71770
22:22:54.794 INFO  Server$ - -- Stats -- connected: 71920
22:22:55.894 INFO  Server$ - -- Stats -- connected: 72066
22:22:56.994 INFO  Server$ - -- Stats -- connected: 72216
22:22:58.094 INFO  Server$ - -- Stats -- connected: 72365
22:22:59.194 INFO  Server$ - -- Stats -- connected: 72515
22:23:00.294 INFO  Server$ - -- Stats -- connected: 72665
22:23:01.395 INFO  Server$ - -- Stats -- connected: 72815
22:23:02.495 INFO  Server$ - -- Stats -- connected: 72963
22:23:03.595 INFO  Server$ - -- Stats -- connected: 73113
22:23:04.695 INFO  Server$ - -- Stats -- connected: 73264
22:23:05.794 INFO  Server$ - -- Stats -- connected: 73411
22:23:06.894 INFO  Server$ - -- Stats -- connected: 73560
22:23:07.994 INFO  Server$ - -- Stats -- connected: 73689
22:23:09.094 INFO  Server$ - -- Stats -- connected: 73816
22:23:10.195 INFO  Server$ - -- Stats -- connected: 73945
22:23:11.295 INFO  Server$ - -- Stats -- connected: 74088
22:23:12.394 INFO  Server$ - -- Stats -- connected: 74215
22:23:13.395 INFO  Server$ - -- Stats -- connected: 74330
22:23:14.495 INFO  Server$ - -- Stats -- connected: 74452
22:23:15.595 INFO  Server$ - -- Stats -- connected: 74579
22:23:16.695 INFO  Server$ - -- Stats -- connected: 74706
22:23:17.794 INFO  Server$ - -- Stats -- connected: 74833
22:23:18.795 INFO  Server$ - -- Stats -- connected: 74948
22:23:19.894 INFO  Server$ - -- Stats -- connected: 75075
22:23:20.895 INFO  Server$ - -- Stats -- connected: 75190
22:23:21.995 INFO  Server$ - -- Stats -- connected: 75317
22:23:23.094 INFO  Server$ - -- Stats -- connected: 75443
22:23:24.095 INFO  Server$ - -- Stats -- connected: 75556
22:23:25.194 INFO  Server$ - -- Stats -- connected: 75683
22:23:26.195 INFO  Server$ - -- Stats -- connected: 75799
22:23:27.294 INFO  Server$ - -- Stats -- connected: 75925
22:23:28.394 INFO  Server$ - -- Stats -- connected: 76052
22:23:29.494 INFO  Server$ - -- Stats -- connected: 76178
22:23:30.594 INFO  Server$ - -- Stats -- connected: 76305
22:23:31.694 INFO  Server$ - -- Stats -- connected: 76432
22:23:32.794 INFO  Server$ - -- Stats -- connected: 76555
22:23:33.895 INFO  Server$ - -- Stats -- connected: 76682
22:23:34.995 INFO  Server$ - -- Stats -- connected: 76809
22:23:36.095 INFO  Server$ - -- Stats -- connected: 76936
22:23:37.195 INFO  Server$ - -- Stats -- connected: 77063
22:23:38.295 INFO  Server$ - -- Stats -- connected: 77189
22:23:39.395 INFO  Server$ - -- Stats -- connected: 77316
22:23:40.495 INFO  Server$ - -- Stats -- connected: 77443
22:23:41.594 INFO  Server$ - -- Stats -- connected: 77570
22:23:42.595 INFO  Server$ - -- Stats -- connected: 77685
22:23:43.695 INFO  Server$ - -- Stats -- connected: 77807
22:23:44.795 INFO  Server$ - -- Stats -- connected: 77934
22:23:45.895 INFO  Server$ - -- Stats -- connected: 78061
22:23:46.995 INFO  Server$ - -- Stats -- connected: 78188
22:23:48.095 INFO  Server$ - -- Stats -- connected: 78315
22:23:49.195 INFO  Server$ - -- Stats -- connected: 78441
22:23:50.294 INFO  Server$ - -- Stats -- connected: 78568
22:23:51.394 INFO  Server$ - -- Stats -- connected: 78695
22:23:52.494 INFO  Server$ - -- Stats -- connected: 78818
22:23:53.594 INFO  Server$ - -- Stats -- connected: 78945
22:23:54.694 INFO  Server$ - -- Stats -- connected: 78992
22:23:55.794 INFO  Server$ - -- Stats -- connected: 78992
22:23:56.894 INFO  Server$ - -- Stats -- connected: 78992
22:23:57.994 INFO  Server$ - -- Stats -- connected: 78992
22:23:59.094 INFO  Server$ - -- Stats -- connected: 78992
22:24:00.194 INFO  Server$ - -- Stats -- connected: 78992
^C22:24:00.729 INFO  Server$ - Shutting down
22:24:00.733 INFO  Server$ - Shutdown complete


Issue comments:
@fbettag I get the following exception when run latest code from master:

[info] Running io.wasted.netty.websocket.bench.Client ws://localhost:5555 50
21:19:49.042 DEBUG i.n.u.i.l.InternalLoggerFactory - Using SLF4J as the default logging framework
21:19:49.046 DEBUG i.n.c.MultithreadEventLoopGroup - io.netty.eventLoopThreads: 8
21:19:49.059 DEBUG i.n.util.internal.PlatformDependent - UID: 501
21:19:49.060 DEBUG i.n.util.internal.PlatformDependent - Java version: 7
21:19:49.062 DEBUG i.n.util.internal.PlatformDependent0 - java.nio.ByteBuffer.cleaner: available
21:19:49.062 DEBUG i.n.util.internal.PlatformDependent0 - java.nio.Buffer.address: available
21:19:49.062 DEBUG i.n.util.internal.PlatformDependent0 - sun.misc.Unsafe.theUnsafe: available
21:19:49.063 DEBUG i.n.util.internal.PlatformDependent0 - sun.misc.Unsafe.copyMemory: available
21:19:49.063 DEBUG i.n.util.internal.PlatformDependent0 - java.nio.Bits.unaligned: true
21:19:49.063 DEBUG i.n.util.internal.PlatformDependent - sun.misc.Unsafe: available
21:19:49.188 DEBUG i.n.util.internal.PlatformDependent - Javassist: available
21:19:49.188 DEBUG i.n.util.internal.PlatformDependent - io.netty.noPreferDirect: false
21:19:49.292 DEBUG i.n.buffer.PooledByteBufAllocator - io.netty.allocator.numHeapArenas: 4
21:19:49.292 DEBUG i.n.buffer.PooledByteBufAllocator - io.netty.allocator.numDirectArenas: 4
21:19:49.292 DEBUG i.n.buffer.PooledByteBufAllocator - io.netty.allocator.pageSize: 8192
21:19:49.292 DEBUG i.n.buffer.PooledByteBufAllocator - io.netty.allocator.maxOrder: 11
21:19:49.292 DEBUG i.n.buffer.PooledByteBufAllocator - io.netty.allocator.chunkSize: 16777216
21:19:49.337 DEBUG io.netty.util.ResourceLeakDetector - io.netty.noResourceLeakDetection: false
21:19:49.345 DEBUG i.n.u.i.JavassistTypeParameterMatcherGenerator - Generated: io.netty.util.internal.**matchers**.io.netty.handler.codec.http.HttpObjectMatcher
21:19:49.411 DEBUG i.n.u.i.JavassistTypeParameterMatcherGenerator - Generated: io.netty.util.internal.**matchers**.io.netty.handler.codec.http.websocketx.WebSocketFrameMatcher
21:19:49.488 INFO  Client$ - All 50 launched
21:19:50.569 WARN  io.netty.util.HashedWheelTimer - An exception was thrown by TimerTask.
java.lang.NullPointerException: null
    at io.wasted.netty.websocket.bench.Client$$anonfun$start$1.apply$mcV$sp(Client.scala:55) ~[classes/:na]
    at io.wasted.netty.websocket.bench.Schedule$$anonfun$io$wasted$netty$websocket$bench$Schedule$$repeatFunc$1.apply$mcV$sp(Schedule.scala:26) ~[classes/:na]
    at io.wasted.netty.websocket.bench.Schedule$$anon$1.run(Schedule.scala:20) ~[classes/:na]
    at io.netty.util.HashedWheelTimer$HashedWheelTimeout.expire(HashedWheelTimer.java:535) ~[netty-all-4.0.0.CR7.jar:na]
    at io.netty.util.HashedWheelTimer$Worker.notifyExpiredTimeouts(HashedWheelTimer.java:433) [netty-all-4.0.0.CR7.jar:na]
    at io.netty.util.HashedWheelTimer$Worker.run(HashedWheelTimer.java:374) [netty-all-4.0.0.CR7.jar:na]
    at java.lang.Thread.run(Thread.java:722) [na:1.7.0_17]
21:19:51.663 WARN  io.netty.util.HashedWheelTimer - An exception was thrown by TimerTask.
java.lang.NullPointerException: null
    at io.wasted.netty.websocket.bench.Client$$anonfun$start$1.apply$mcV$sp(Client.scala:55) ~[classes/:na]
    at io.wasted.netty.websocket.bench.Schedule$$anonfun$io$wasted$netty$websocket$bench$Schedule$$repeatFunc$1.apply$mcV$sp(Schedule.scala:26) ~[classes/:na]
    at io.wasted.netty.websocket.bench.Schedule$$anon$1.run(Schedule.scala:20) ~[classes/:na]
    at io.netty.util.HashedWheelTimer$HashedWheelTimeout.expire(HashedWheelTimer.java:535) ~[netty-all-4.0.0.CR7.jar:na]
    at io.netty.util.HashedWheelTimer$Worker.notifyExpiredTimeouts(HashedWheelTimer.java:433) [netty-all-4.0.0.CR7.jar:na]
    at io.netty.util.HashedWheelTimer$Worker.run(HashedWheelTimer.java:374) [netty-all-4.0.0.CR7.jar:na]
    at java.lang.Thread.run(Thread.java:722) [na:1.7.0_17]
21:19:52.763 WARN  io.netty.util.HashedWheelTimer - An exception was thrown by TimerTask.
java.lang.NullPointerException: null
    at io.wasted.netty.websocket.bench.Client$$anonfun$start$1.apply$mcV$sp(Client.scala:55) ~[classes/:na]
    at io.wasted.netty.websocket.bench.Schedule$$anonfun$io$wasted$netty$websocket$bench$Schedule$$repeatFunc$1.apply$mcV$sp(Schedule.scala:26) ~[classes/:na]
    at io.wasted.netty.websocket.bench.Schedule$$anon$1.run(Schedule.scala:20) ~[classes/:na]
    at io.netty.util.HashedWheelTimer$HashedWheelTimeout.expire(HashedWheelTimer.java:535) ~[netty-all-4.0.0.CR7.jar:na]
    at io.netty.util.HashedWheelTimer$Worker.notifyExpiredTimeouts(HashedWheelTimer.java:433) [netty-all-4.0.0.CR7.jar:na]
    at io.netty.util.HashedWheelTimer$Worker.run(HashedWheelTimer.java:374) [netty-all-4.0.0.CR7.jar:na]
    at java.lang.Thread.run(Thread.java:722) [na:1.7.0_17]

Dont pay attention to the client, i wanted to output stats but decided otherwise. Will cean it up, doesnt have impact tho.

@fbettag don't call retain on the request when pass it to the handshakeer. This will fix it. I have added some explanation to the javadocs to make this clear.


Pull request review comments:

Patch that resolved the issue:
diff --git a/common/src/main/java/io/netty/util/ResourceLeakException.java b/common/src/main/java/io/netty/util/ResourceLeakException.java
index a69238884bf..d1bdec0c4ff 100644
--- a/common/src/main/java/io/netty/util/ResourceLeakException.java
+++ b/common/src/main/java/io/netty/util/ResourceLeakException.java
@@ -16,6 +16,8 @@
 
 package io.netty.util;
 
+import io.netty.util.internal.StringUtil;
+
 import java.util.Arrays;
 
 public class ResourceLeakException extends RuntimeException {
@@ -64,4 +66,15 @@ public boolean equals(Object o) {
 
         return Arrays.equals(cachedStackTrace, ((ResourceLeakException) o).cachedStackTrace);
     }
+
+    @Override
+    public String toString() {
+        final StringBuilder builder = new StringBuilder();
+        builder.append(this.getClass().getCanonicalName()).append(": ").append(getMessage());
+        for (StackTraceElement element : cachedStackTrace) {
+          builder.append(StringUtil.NEWLINE).append("  at ").append(element);
+        }
+
+        return builder.toString();
+    }
 }


Test patch: