You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@zookeeper.apache.org by an...@apache.org on 2020/01/21 16:53:55 UTC
[zookeeper] branch branch-3.6 updated: ZOOKEEPER-3669: Use switch
Statement in ClientCnxn SendThread
This is an automated email from the ASF dual-hosted git repository.
andor pushed a commit to branch branch-3.6
in repository https://gitbox.apache.org/repos/asf/zookeeper.git
The following commit(s) were added to refs/heads/branch-3.6 by this push:
new ad425ce ZOOKEEPER-3669: Use switch Statement in ClientCnxn SendThread
ad425ce is described below
commit ad425cea0fae18619653154a48a7699b8f40ed0a
Author: David Mollitor <dm...@apache.org>
AuthorDate: Tue Jan 21 17:53:18 2020 +0100
ZOOKEEPER-3669: Use switch Statement in ClientCnxn SendThread
Author: David Mollitor <dm...@apache.org>
Reviewers: fangmin@apache.org, andor@apache.org
Closes #1197 from belugabehr/ZOOKEEPER-3669
(cherry picked from commit 517ecde9dd3cfe574118231ec242ea73b80a4e79)
Signed-off-by: Andor Molnar <an...@apache.org>
---
.../main/java/org/apache/zookeeper/ClientCnxn.java | 34 +++++++++++-----------
1 file changed, 17 insertions(+), 17 deletions(-)
diff --git a/zookeeper-server/src/main/java/org/apache/zookeeper/ClientCnxn.java b/zookeeper-server/src/main/java/org/apache/zookeeper/ClientCnxn.java
index 3859382..d3d8e85 100644
--- a/zookeeper-server/src/main/java/org/apache/zookeeper/ClientCnxn.java
+++ b/zookeeper-server/src/main/java/org/apache/zookeeper/ClientCnxn.java
@@ -867,24 +867,24 @@ public class ClientCnxn {
ReplyHeader replyHdr = new ReplyHeader();
replyHdr.deserialize(bbia, "header");
- if (replyHdr.getXid() == PING_XID) {
- LOG.debug(
- "Got ping response for session id: 0x{} after {}ms.",
+ switch (replyHdr.getXid()) {
+ case PING_XID:
+ LOG.debug("Got ping response for session id: 0x{} after {}ms.",
Long.toHexString(sessionId),
((System.nanoTime() - lastPingSentNs) / 1000000));
return;
- }
- if (replyHdr.getXid() == AUTHPACKET_XID) {
+ case AUTHPACKET_XID:
+ LOG.debug("Got auth session id: 0x{}", Long.toHexString(sessionId));
if (replyHdr.getErr() == KeeperException.Code.AUTHFAILED.intValue()) {
state = States.AUTH_FAILED;
- eventThread.queueEvent(new WatchedEvent(Watcher.Event.EventType.None, Watcher.Event.KeeperState.AuthFailed, null));
+ eventThread.queueEvent(new WatchedEvent(Watcher.Event.EventType.None,
+ Watcher.Event.KeeperState.AuthFailed, null));
eventThread.queueEventOfDeath();
}
- LOG.debug("Got auth session id: 0x{}", Long.toHexString(sessionId));
- return;
- }
- if (replyHdr.getXid() == NOTIFICATION_XID) {
- LOG.debug("Got notification session id: 0x{}", Long.toHexString(sessionId));
+ return;
+ case NOTIFICATION_XID:
+ LOG.debug("Got notification session id: 0x{}",
+ Long.toHexString(sessionId));
WatcherEvent event = new WatcherEvent();
event.deserialize(bbia, "response");
@@ -895,18 +895,18 @@ public class ClientCnxn {
event.setPath("/");
} else if (serverPath.length() > chrootPath.length()) {
event.setPath(serverPath.substring(chrootPath.length()));
- } else {
- LOG.warn(
- "Got server path {} which is too short for chroot path {}.",
- event.getPath(),
- chrootPath);
- }
+ } else {
+ LOG.warn("Got server path {} which is too short for chroot path {}.",
+ event.getPath(), chrootPath);
+ }
}
WatchedEvent we = new WatchedEvent(event);
LOG.debug("Got {} for session id 0x{}", we, Long.toHexString(sessionId));
eventThread.queueEvent(we);
return;
+ default:
+ break;
}
// If SASL authentication is currently in progress, construct and