RedisLockUtil加锁解锁方法名修复sonar.LocksNotUnlockedCheck

This commit is contained in:
gaoqr
2025-05-22 09:32:00 +08:00
parent e0bfeb6567
commit 2f78e41313
9 changed files with 23 additions and 23 deletions
@@ -341,7 +341,7 @@ public class WebCadOrderImportServiceImpl implements WebCadOrderImportService {
private void addSyncLock(Long organId) {
String importLockKey = String.format(RedisKeyConstants.ORDER_IMPORT_LOCK_KEY, organId);
// 检查机构导入锁
boolean lockResult = redisLockUtil.lock(importLockKey, REDIS_UNIQUEKEY, chenfengCacheProperties.getLockTimeout());
boolean lockResult = redisLockUtil.acquireLock(importLockKey, REDIS_UNIQUEKEY, chenfengCacheProperties.getLockTimeout());
if (!lockResult) {
throw new ServiceException(ORDER_IMPORT_ORGAN_LOCK_ERROR);
}
@@ -355,7 +355,7 @@ public class WebCadOrderImportServiceImpl implements WebCadOrderImportService {
private void addAsyncLock(Long taskId) {
String importLockKey = String.format(RedisKeyConstants.ORDER_IMPORT_LOCK_KEY, getUserOrganId());
// 检查机构导入锁
boolean lockResult = redisLockUtil.lock(importLockKey, String.valueOf(taskId), chenfengCacheProperties.getLockTimeout());
boolean lockResult = redisLockUtil.acquireLock(importLockKey, String.valueOf(taskId), chenfengCacheProperties.getLockTimeout());
if (!lockResult) {
throw new ServiceException(ORDER_IMPORT_ORGAN_LOCK_ERROR);
}
@@ -367,11 +367,11 @@ public class WebCadOrderImportServiceImpl implements WebCadOrderImportService {
private void unlock(boolean sync, boolean initAsyncSuccess, Long organId, Long taskId) {
if(sync) {
// 解同步锁
redisLockUtil.unlock(String.format(RedisKeyConstants.ORDER_IMPORT_LOCK_KEY, organId), REDIS_UNIQUEKEY);
redisLockUtil.releaseLock(String.format(RedisKeyConstants.ORDER_IMPORT_LOCK_KEY, organId), REDIS_UNIQUEKEY);
} else {
// 异步发送消息失败了,解开异步锁
if (!initAsyncSuccess && ObjectUtil.isNotNull(taskId)) {
redisLockUtil.unlock(String.format(RedisKeyConstants.ORDER_IMPORT_LOCK_KEY, organId), String.valueOf(taskId));
redisLockUtil.releaseLock(String.format(RedisKeyConstants.ORDER_IMPORT_LOCK_KEY, organId), String.valueOf(taskId));
}
}
}
@@ -154,7 +154,7 @@ public class DefaultExcelOrderImportConsumer {
// 手动确认消息接收
channel.basicAck(deliveryTag, false);
// 导入锁解锁
redisLockUtil.unlock(String.format(RedisKeyConstants.ORDER_IMPORT_LOCK_KEY, organId), message);
redisLockUtil.releaseLock(String.format(RedisKeyConstants.ORDER_IMPORT_LOCK_KEY, organId), message);
}
}
@@ -150,7 +150,7 @@ public class DefaultXmlOrderImportConsumer {
// 手动确认消息接收
channel.basicAck(deliveryTag, false);
// 导入锁解锁
redisLockUtil.unlock(String.format(RedisKeyConstants.ORDER_IMPORT_LOCK_KEY, organId), message);
redisLockUtil.releaseLock(String.format(RedisKeyConstants.ORDER_IMPORT_LOCK_KEY, organId), message);
}
}
@@ -85,7 +85,7 @@ public class OrderImportDeadLetterConsumer {
// 导入锁解锁
if (ObjectUtil.isNotNull(organId)) {
redisLockUtil.unlock(String.format(RedisKeyConstants.ORDER_IMPORT_LOCK_KEY, organId), message);
redisLockUtil.releaseLock(String.format(RedisKeyConstants.ORDER_IMPORT_LOCK_KEY, organId), message);
}
}
@@ -183,7 +183,7 @@ public class WebCadOrderImportConsumer {
channel.basicAck(deliveryTag, false);
}
// 导入锁解锁
redisLockUtil.unlock(String.format(RedisKeyConstants.ORDER_IMPORT_LOCK_KEY, organId), message);
redisLockUtil.releaseLock(String.format(RedisKeyConstants.ORDER_IMPORT_LOCK_KEY, organId), message);
}
}