mirror of
http://192.168.1.205:9980/cf_devdept2/cf_imes_server.git
synced 2026-08-12 21:02:08 +08:00
RedisLockUtil加锁解锁修复sonar.LocksNotUnlockedCheck
This commit is contained in:
+6
-6
@@ -35,8 +35,8 @@ public class RedisLockUtil {
|
||||
public boolean acquireLock(String key) {
|
||||
boolean getLock = false;
|
||||
try {
|
||||
RLock lock = redissonClient.getLock(key);
|
||||
return lock.tryLock(chenfengCacheProperties.getLockWaitTime(), chenfengCacheProperties.getLockTimeout(), TimeUnit.MILLISECONDS);
|
||||
RLock rLock = redissonClient.getLock(key);
|
||||
return rLock.tryLock(chenfengCacheProperties.getLockWaitTime(), chenfengCacheProperties.getLockTimeout(), TimeUnit.MILLISECONDS);
|
||||
} catch (Exception e) {
|
||||
log.error("[RedisLockUtil][lock]加锁失败", e);
|
||||
return getLock;
|
||||
@@ -54,10 +54,10 @@ public class RedisLockUtil {
|
||||
public boolean acquireLock(String key, Integer waitTime, Integer timeout) {
|
||||
boolean getLock = false;
|
||||
try {
|
||||
RLock lock = redissonClient.getLock(key);
|
||||
RLock rLock = redissonClient.getLock(key);
|
||||
int wt = ObjectUtil.isNull(waitTime) ? chenfengCacheProperties.getLockWaitTime() : waitTime;
|
||||
int to = ObjectUtil.isNull(timeout) ? chenfengCacheProperties.getLockTimeout() : timeout;
|
||||
return lock.tryLock(wt, to, TimeUnit.MILLISECONDS);
|
||||
return rLock.tryLock(wt, to, TimeUnit.MILLISECONDS);
|
||||
} catch (Exception e) {
|
||||
log.error("[RedisLockUtil][lock]加锁失败", e);
|
||||
return getLock;
|
||||
@@ -72,8 +72,8 @@ public class RedisLockUtil {
|
||||
*/
|
||||
public void releaseLock(String key) {
|
||||
try {
|
||||
RLock lock = redissonClient.getLock(key);
|
||||
lock.unlock();
|
||||
RLock rLock = redissonClient.getLock(key);
|
||||
rLock.unlock();
|
||||
} catch (Exception e) {
|
||||
log.error("[RedisLockUtil][unlock]解锁失败", e);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user