This is an automated email from the ASF dual-hosted git repository. andor pushed a commit to branch branch-3.8 in repository https://gitbox.apache.org/repos/asf/zookeeper.git
The following commit(s) were added to refs/heads/branch-3.8 by this push: new ec16d4eb1 ZOOKEEPER-910: Use SelectionKey.isXYZ() methods instead of complicated binary logic ec16d4eb1 is described below commit ec16d4eb1a1fc78bc8d74b5b76568b722515c7fe 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 (cherry picked from commit 6c2d94d04954224f29479529d8790eb1b3fd6489) Signed-off-by: Andor Molnar <an...@apache.org> --- .../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); } }