You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by ch...@apache.org on 2023/05/15 02:49:08 UTC
[shardingsphere] branch master updated: Fix sonar issue of EtcdDistributedLock (#25668)
This is an automated email from the ASF dual-hosted git repository.
chengzhang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new a7ff81a2026 Fix sonar issue of EtcdDistributedLock (#25668)
a7ff81a2026 is described below
commit a7ff81a2026c81b972852db63756a52c052f72bf
Author: zhaojinchao <zh...@apache.org>
AuthorDate: Mon May 15 10:49:02 2023 +0800
Fix sonar issue of EtcdDistributedLock (#25668)
* Fix sonar issue of EtcdDistributedLock
* Fix checkstyle
---
.../mode/repository/cluster/etcd/lock/EtcdDistributedLock.java | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/mode/type/cluster/repository/provider/etcd/src/main/java/org/apache/shardingsphere/mode/repository/cluster/etcd/lock/EtcdDistributedLock.java b/mode/type/cluster/repository/provider/etcd/src/main/java/org/apache/shardingsphere/mode/repository/cluster/etcd/lock/EtcdDistributedLock.java
index e6252574c37..41427da3476 100644
--- a/mode/type/cluster/repository/provider/etcd/src/main/java/org/apache/shardingsphere/mode/repository/cluster/etcd/lock/EtcdDistributedLock.java
+++ b/mode/type/cluster/repository/provider/etcd/src/main/java/org/apache/shardingsphere/mode/repository/cluster/etcd/lock/EtcdDistributedLock.java
@@ -26,7 +26,9 @@ import org.apache.shardingsphere.mode.repository.cluster.etcd.props.EtcdProperty
import org.apache.shardingsphere.mode.repository.cluster.lock.DistributedLock;
import java.nio.charset.StandardCharsets;
+import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
/**
* Etcd distributed lock.
@@ -53,9 +55,7 @@ public final class EtcdDistributedLock implements DistributedLock {
try {
lock.lock(lockKey, lease.grant(timeToLiveSeconds).get().getID()).get(timeoutMillis, TimeUnit.MILLISECONDS);
return true;
- // CHECKSTYLE:OFF
- } catch (final Exception ignored) {
- // CHECKSTYLE:ON
+ } catch (final InterruptedException | ExecutionException | TimeoutException ignored) {
return false;
}
}
@@ -64,9 +64,7 @@ public final class EtcdDistributedLock implements DistributedLock {
public void unlock() {
try {
lock.unlock(lockKey).get();
- // CHECKSTYLE:OFF
- } catch (final Exception ignored) {
- // CHECKSTYLE:ON
+ } catch (final InterruptedException | ExecutionException ignored) {
}
}
}