Github user eolivelli commented on a diff in the pull request: https://github.com/apache/zookeeper/pull/669#discussion_r226684843 --- Diff: zookeeper-common/src/main/java/org/apache/zookeeper/ClientCnxnSocketNetty.java --- @@ -439,13 +466,34 @@ public void messageReceived(ChannelHandlerContext ctx, } } wakeupCnxn(); + // Note: SimpleChannelInboundHandler releases the ByteBuf for us + // so we don't need to do it. } @Override - public void exceptionCaught(ChannelHandlerContext ctx, - ExceptionEvent e) throws Exception { - LOG.warn("Exception caught: {}", e, e.getCause()); + public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) { + LOG.warn("Exception caught", cause); cleanup(); } } + + /** + * Sets the test ByteBufAllocator. This allocator will be used by all + * future instances of this class. + * It is not recommended to use this method outside of testing. + * @param allocator the ByteBufAllocator to use for all netty buffer + * allocations. + */ + public static void setTestAllocator(ByteBufAllocator allocator) { + TEST_ALLOCATOR.set(allocator); --- End diff -- I think this is a security hole. We are in the client, so untrusted code may call this public method. We should use mockito/powermock for this stuff. Is there are another way?
---