This is an automated email from the ASF dual-hosted git repository.
andor pushed a commit to branch branch-3.9
in repository https://gitbox.apache.org/repos/asf/zookeeper.git
The following commit(s) were added to refs/heads/branch-3.9 by this push:
new 3736f0e98 ZOOKEEPER-910: Use SelectionKey.isXYZ() methods instead of
complicated binary logic
3736f0e98 is described below
commit 3736f0e981247f48f2176055c9cfc634194cfa9e
Author: tison <[email protected]>
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 <[email protected]>
Co-authored-by: Michi Mutsuzaki <[email protected]>
Reviewers: kezhuw, anmolnar
Author: tisonkun
Closes #2063 from tisonkun/ZOOKEEPER-910
(cherry picked from commit 6c2d94d04954224f29479529d8790eb1b3fd6489)
Signed-off-by: Andor Molnar <[email protected]>
---
.../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);
}
}