title: Newbie: Tripped a warning: WARN io.netty.util.ReferenceCountUtil - Failed to release a message
body: <p>Netty 4.1.6 (io.netty:netty-all:4.1.6.Final from Gradle via jcenter() with Java 1.8.0_102 on OS X 10.11.6)  <em>claims</em> this is a warning, but it actually causes my code not to do the right thing.  Being totally new to Netty, I'm almost certainly screwing something up, so I thought I'd ask the experts.</p>
  
  <p>I get:</p>
  
  <pre><code>[nioEventLoopGroup-2-1] WARN io.netty.util.ReferenceCountUtil - Failed to release a message: DatagramPacket(=&gt; /127.0.0.1:54169, PooledUnsafeDirectByteBuf(freed))
  io.netty.util.IllegalReferenceCountException: refCnt: 0, decrement: 1
  </code></pre>
  
  <p>from this code:</p>
  
  <pre><code>public void channelRead0(ChannelHandlerContext ctx, DatagramPacket packet) throws Exception {
      ByteBuf bb = Unpooled.copiedBuffer(packet.content());
  
      String ssHex = javax.xml.bind.DatatypeConverter.printHexBinary(bb.array());     
      System.out.println("IP:"+packet.sender()+":"+packet.recipient()+":"+ssHex);
  
      DatagramPacket udpPacket = new DatagramPacket(packet.content(), packet.sender());  // Using this line causes the exception at write
      //DatagramPacket udpPacket = new DatagramPacket(bb, packet.sender());  // Using this line succeeds
      ctx.write(udpPacket);  // Exception is thrown here
  }
  </code></pre>
  
  <p>What am I doing wrong?  Thanks for any help.</p>
  
  <p>Full Exception:</p>
  
  <pre><code>[nioEventLoopGroup-2-1] WARN io.netty.util.ReferenceCountUtil - Failed to release a message: DatagramPacket(=&gt; /127.0.0.1:54169, PooledUnsafeDirectByteBuf(freed))
  io.netty.util.IllegalReferenceCountException: refCnt: 0, decrement: 1
      at io.netty.buffer.AbstractReferenceCountedByteBuf.release0(AbstractReferenceCountedByteBuf.java:110)
      at io.netty.buffer.AbstractReferenceCountedByteBuf.release(AbstractReferenceCountedByteBuf.java:98)
      at io.netty.util.ReferenceCountUtil.release(ReferenceCountUtil.java:84)
      at io.netty.channel.DefaultAddressedEnvelope.release(DefaultAddressedEnvelope.java:101)
      at io.netty.util.ReferenceCountUtil.release(ReferenceCountUtil.java:84)
      at io.netty.util.ReferenceCountUtil.safeRelease(ReferenceCountUtil.java:109)
      at io.netty.channel.ChannelOutboundBuffer.remove0(ChannelOutboundBuffer.java:296)
      at io.netty.channel.ChannelOutboundBuffer.failFlushed(ChannelOutboundBuffer.java:621)
      at io.netty.channel.AbstractChannel$AbstractUnsafe.flush0(AbstractChannel.java:869)
      at io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe.flush0(AbstractNioChannel.java:362)
      at io.netty.channel.AbstractChannel$AbstractUnsafe.flush(AbstractChannel.java:823)
      at io.netty.channel.DefaultChannelPipeline$HeadContext.flush(DefaultChannelPipeline.java:1296)
      at io.netty.channel.AbstractChannelHandlerContext.invokeFlush0(AbstractChannelHandlerContext.java:787)
      at io.netty.channel.AbstractChannelHandlerContext.invokeFlush(AbstractChannelHandlerContext.java:779)
      at io.netty.channel.AbstractChannelHandlerContext.flush(AbstractChannelHandlerContext.java:760)
      at com.foobar.uservices.initial_receiver.InitialReceiverHandler.channelReadComplete(InitialReceiverHandler.java:24)
      at io.netty.channel.AbstractChannelHandlerContext.invokeChannelReadComplete(AbstractChannelHandlerContext.java:409)
      at io.netty.channel.AbstractChannelHandlerContext.invokeChannelReadComplete(AbstractChannelHandlerContext.java:391)
      at io.netty.channel.AbstractChannelHandlerContext.fireChannelReadComplete(AbstractChannelHandlerContext.java:384)
      at io.netty.channel.DefaultChannelPipeline$HeadContext.channelReadComplete(DefaultChannelPipeline.java:1339)
      at io.netty.channel.AbstractChannelHandlerContext.invokeChannelReadComplete(AbstractChannelHandlerContext.java:409)
      at io.netty.channel.AbstractChannelHandlerContext.invokeChannelReadComplete(AbstractChannelHandlerContext.java:391)
      at io.netty.channel.DefaultChannelPipeline.fireChannelReadComplete(DefaultChannelPipeline.java:932)
      at io.netty.channel.nio.AbstractNioMessageChannel$NioMessageUnsafe.read(AbstractNioMessageChannel.java:97)
      at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:651)
      at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:574)
      at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:488)
      at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:450)
      at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:873)
      at io.netty.util.concurrent.DefaultThreadFactory$DefaultRunnableDecorator.run(DefaultThreadFactory.java:144)
      at java.lang.Thread.run(Thread.java:745)
  </code></pre>