@Lock空值时不设置锁

SpringBoot升级至2.2.7.RELEASE
master
toesbieya 6 years ago
parent 2952d9825b
commit a8fcd3c3ab
  1. 2
      java/pom.xml
  2. 7
      java/src/main/java/com/toesbieya/my/aspect/LockAspect.java

@ -5,7 +5,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.1.RELEASE</version>
<version>2.2.7.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.toesbieya</groupId>

@ -12,6 +12,7 @@ import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import java.lang.reflect.Method;
import java.util.ArrayList;
@ -41,11 +42,11 @@ public class LockAspect {
Object[] args = point.getArgs();
for (String v : values) {
String lockKey = (String) SpringUtil.spell(v, parameterNames, args);
//跳过空值
if (StringUtils.isEmpty(lockKey)) continue;
LockHelper lockHelper = new RedisLockHelper(lockKey);
if (!lockHelper.lock()) {
if (locks.size() > 0) {
locks.forEach(LockHelper::close);
}
locks.forEach(LockHelper::close);
return Result.fail("操作失败,请刷新后重试");
}
locks.add(lockHelper);

Loading…
Cancel
Save