This is an automated email from the ASF dual-hosted git repository.

andor pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/zookeeper.git


The following commit(s) were added to refs/heads/master by this push:
     new 6c2d94d04 ZOOKEEPER-910: Use SelectionKey.isXYZ() methods instead of 
complicated binary logic
6c2d94d04 is described below

commit 6c2d94d04954224f29479529d8790eb1b3fd6489
Author: tison <wander4...@gmail.com>
AuthorDate: Fri Dec 1 00:30:13 2023 +0800

    ZOOKEEPER-910: Use SelectionKey.isXYZ() methods instead of complicated 
binary logic
    
    ZOOKEEPER-910: Use SelectionKey.isXYZ() methods instead of complicated 
binary logic
    
    Signed-off-by: tison <wander4...@gmail.com>
    Co-authored-by: Michi Mutsuzaki <mic...@apache.org>
    Reviewers: kezhuw, anmolnar
    Author: tisonkun
    Closes #2063 from tisonkun/ZOOKEEPER-910
---
 .../src/main/java/org/apache/zookeeper/ClientCnxnSocketNIO.java     | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git 
a/zookeeper-server/src/main/java/org/apache/zookeeper/ClientCnxnSocketNIO.java 
b/zookeeper-server/src/main/java/org/apache/zookeeper/ClientCnxnSocketNIO.java
index 6cb125dc7..3ecce4c88 100644
--- 
a/zookeeper-server/src/main/java/org/apache/zookeeper/ClientCnxnSocketNIO.java
+++ 
b/zookeeper-server/src/main/java/org/apache/zookeeper/ClientCnxnSocketNIO.java
@@ -335,18 +335,18 @@ public class ClientCnxnSocketNIO extends ClientCnxnSocket 
{
             selected = selector.selectedKeys();
         }
         // Everything below and until we get back to the select is
-        // non blocking, so time is effectively a constant. That is
+        // non-blocking, so time is effectively a constant. That is
         // Why we just have to do this once, here
         updateNow();
         for (SelectionKey k : selected) {
             SocketChannel sc = ((SocketChannel) k.channel());
-            if ((k.readyOps() & SelectionKey.OP_CONNECT) != 0) {
+            if (k.isConnectable()) {
                 if (sc.finishConnect()) {
                     updateLastSendAndHeard();
                     updateSocketAddresses();
                     sendThread.primeConnection();
                 }
-            } else if ((k.readyOps() & (SelectionKey.OP_READ | 
SelectionKey.OP_WRITE)) != 0) {
+            } else if (k.isReadable() || k.isWritable()) {
                 doIO(pendingQueue, cnxn);
             }
         }

Reply via email to