You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by su...@apache.org on 2022/11/05 03:12:50 UTC

[shardingsphere] branch master updated: Remove useless LockContext.isLocked() (#21968)

This is an automated email from the ASF dual-hosted git repository.

sunnianjun 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 8ce11a8f8d4 Remove useless LockContext.isLocked() (#21968)
8ce11a8f8d4 is described below

commit 8ce11a8f8d4bc64538ab201cfb6ee2a65b6a7ee6
Author: Liang Zhang <zh...@apache.org>
AuthorDate: Sat Nov 5 11:12:43 2022 +0800

    Remove useless LockContext.isLocked() (#21968)
---
 .../org/apache/shardingsphere/infra/lock/LockContext.java   |  8 --------
 .../apache/shardingsphere/mode/lock/GlobalLockContext.java  | 13 +++----------
 .../shardingsphere/mode/lock/GlobalLockContextTest.java     |  6 ------
 3 files changed, 3 insertions(+), 24 deletions(-)

diff --git a/infra/common/src/main/java/org/apache/shardingsphere/infra/lock/LockContext.java b/infra/common/src/main/java/org/apache/shardingsphere/infra/lock/LockContext.java
index 47fb6ddfeea..a74f1411e3c 100644
--- a/infra/common/src/main/java/org/apache/shardingsphere/infra/lock/LockContext.java
+++ b/infra/common/src/main/java/org/apache/shardingsphere/infra/lock/LockContext.java
@@ -39,12 +39,4 @@ public interface LockContext<T extends LockDefinition> {
      * @param lockDefinition lock definition
      */
     void unlock(T lockDefinition);
-    
-    /**
-     *  Is locked.
-     *
-     * @param lockDefinition lock definition
-     * @return is locked or not
-     */
-    boolean isLocked(LockDefinition lockDefinition);
 }
diff --git a/mode/core/src/main/java/org/apache/shardingsphere/mode/lock/GlobalLockContext.java b/mode/core/src/main/java/org/apache/shardingsphere/mode/lock/GlobalLockContext.java
index ad4d9a2b052..59d07d24d6d 100644
--- a/mode/core/src/main/java/org/apache/shardingsphere/mode/lock/GlobalLockContext.java
+++ b/mode/core/src/main/java/org/apache/shardingsphere/mode/lock/GlobalLockContext.java
@@ -19,8 +19,6 @@ package org.apache.shardingsphere.mode.lock;
 
 import lombok.RequiredArgsConstructor;
 import org.apache.shardingsphere.infra.lock.LockContext;
-import org.apache.shardingsphere.infra.lock.LockDefinition;
-import org.apache.shardingsphere.infra.util.exception.external.sql.type.generic.UnsupportedSQLOperationException;
 
 /**
  * Global lock context.
@@ -28,20 +26,15 @@ import org.apache.shardingsphere.infra.util.exception.external.sql.type.generic.
 @RequiredArgsConstructor
 public final class GlobalLockContext implements LockContext<GlobalLockDefinition> {
     
-    private final LockPersistService<GlobalLockDefinition> lockPersistService;
+    private final LockPersistService<GlobalLockDefinition> globalLockPersistService;
     
     @Override
     public boolean tryLock(final GlobalLockDefinition lockDefinition, final long timeoutMillis) {
-        return lockPersistService.tryLock(lockDefinition, timeoutMillis);
+        return globalLockPersistService.tryLock(lockDefinition, timeoutMillis);
     }
     
     @Override
     public void unlock(final GlobalLockDefinition lockDefinition) {
-        lockPersistService.unlock(lockDefinition);
-    }
-    
-    @Override
-    public boolean isLocked(final LockDefinition lockDefinition) {
-        throw new UnsupportedSQLOperationException("isLocked");
+        globalLockPersistService.unlock(lockDefinition);
     }
 }
diff --git a/mode/core/src/test/java/org/apache/shardingsphere/mode/lock/GlobalLockContextTest.java b/mode/core/src/test/java/org/apache/shardingsphere/mode/lock/GlobalLockContextTest.java
index b089df93ba1..0be707d1fdb 100644
--- a/mode/core/src/test/java/org/apache/shardingsphere/mode/lock/GlobalLockContextTest.java
+++ b/mode/core/src/test/java/org/apache/shardingsphere/mode/lock/GlobalLockContextTest.java
@@ -17,7 +17,6 @@
 
 package org.apache.shardingsphere.mode.lock;
 
-import org.apache.shardingsphere.infra.util.exception.external.sql.type.generic.UnsupportedSQLOperationException;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -54,9 +53,4 @@ public final class GlobalLockContextTest {
         lockContext.unlock(lockDefinition);
         verify(lockPersistService).unlock(lockDefinition);
     }
-    
-    @Test(expected = UnsupportedSQLOperationException.class)
-    public void assertIsLocked() {
-        lockContext.isLocked(lockDefinition);
-    }
 }