Github user ivmaykov commented on a diff in the pull request:
https://github.com/apache/zookeeper/pull/669#discussion_r226756353
--- 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 --
Sure, but that would only affect that client and would have no effect on
the server. All clients are untrusted by default since they run on a computer
you don't own :)
I can look into using a mocking framework instead if you feel strongly
about it.
---