From 6f123d03b5d9567ebfa4d8c5bb356f59d590d34e Mon Sep 17 00:00:00 2001 From: lordchen1020 <1572139390@qq.com> Date: Thu, 14 Oct 2021 21:32:20 +0800 Subject: [PATCH] Accessing the static variables and methods of the class through the object reference of this class will increase the cost of the compiler's analysis. A better way is to directly use the class name to access the static variables or methods. --- .../org/apache/bookkeeper/metadata/etcd/EtcdWatchClient.java | 4 ++-- .../java/org/apache/distributedlog/lock/ZKSessionLock.java | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/metadata-drivers/etcd/src/main/java/org/apache/bookkeeper/metadata/etcd/EtcdWatchClient.java b/metadata-drivers/etcd/src/main/java/org/apache/bookkeeper/metadata/etcd/EtcdWatchClient.java index 381ebfa1811..187f45c3505 100644 --- a/metadata-drivers/etcd/src/main/java/org/apache/bookkeeper/metadata/etcd/EtcdWatchClient.java +++ b/metadata-drivers/etcd/src/main/java/org/apache/bookkeeper/metadata/etcd/EtcdWatchClient.java @@ -223,7 +223,7 @@ private void processError(Throwable t) { } Status status = Status.fromThrowable(t); - if (this.isHaltError(status) || this.isNoLeaderError(status)) { + if (EtcdWatchClient.isHaltError(status) || EtcdWatchClient.isNoLeaderError(status)) { this.notifyWatchers(toEtcdException(status)); this.closeGrpcWatchStreamObserver(); this.cancelSet.clear(); @@ -291,7 +291,7 @@ private void processCreate(WatchResponse response) { private Optional nextResume() { EtcdWatcher pendingWatcher = this.pendingWatchers.peek(); if (pendingWatcher != null) { - return Optional.of(this.toWatchCreateRequest(pendingWatcher)); + return Optional.of(EtcdWatchClient.toWatchCreateRequest(pendingWatcher)); } return Optional.empty(); } diff --git a/stream/distributedlog/core/src/main/java/org/apache/distributedlog/lock/ZKSessionLock.java b/stream/distributedlog/core/src/main/java/org/apache/distributedlog/lock/ZKSessionLock.java index e776ee90e19..e88912d4fc6 100644 --- a/stream/distributedlog/core/src/main/java/org/apache/distributedlog/lock/ZKSessionLock.java +++ b/stream/distributedlog/core/src/main/java/org/apache/distributedlog/lock/ZKSessionLock.java @@ -924,7 +924,7 @@ private void claimOwnership(int lockEpoch) { private void unlockInternal(final CompletableFuture promise) { // already closed or expired, nothing to cleanup - this.epochUpdater.incrementAndGet(this); + ZKSessionLock.epochUpdater.incrementAndGet(this); if (null != watcher) { this.zkClient.unregister(watcher); }