zookeeper-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] ivmaykov commented on a change in pull request #819: ZOOKEEPER-3272: Clean up netty4 code per Norman Maurer's review comments
Date Wed, 13 Feb 2019 22:04:44 GMT
ivmaykov commented on a change in pull request #819: ZOOKEEPER-3272: Clean up netty4 code per
Norman Maurer's review comments
URL: https://github.com/apache/zookeeper/pull/819#discussion_r256609116
 
 

 ##########
 File path: zookeeper-server/src/main/java/org/apache/zookeeper/server/NettyServerCnxnFactory.java
 ##########
 @@ -192,14 +192,16 @@ public void channelRead(ChannelHandlerContext ctx, Object msg) throws
Exception
             }
         }
 
-        @Override
-        public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise)
throws Exception {
+        // Use a single listener instance to reduce GC
+        private final GenericFutureListener<Future<Void>> onWriteCompletedListener
= (f) -> {
             if (LOG.isTraceEnabled()) {
-                promise.addListener((future) -> {
-                    LOG.trace("write {}",
-                            future.isSuccess() ? "complete" : "failed");
-                });
+                LOG.trace("write {}", f.isSuccess() ? "complete" : "failed");
             }
+        };
+
+        @Override
+        public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise)
throws Exception {
+            promise.addListener(onWriteCompletedListener);
 
 Review comment:
   I had this code originally and @eolivelli asked me to change it to do the `if (LOG.isTraceEnabled())`
check inside the listener. I guess I can do both. Will fix this backport and will open a new
PR against master.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message