修复@Lock注解解锁报错

This commit is contained in:
zlt2000
2020-09-07 12:56:11 +08:00
parent f51238944a
commit 72c1041682
2 changed files with 4 additions and 2 deletions
@@ -65,6 +65,8 @@ public interface DistributedLock {
* @param zLock 锁抽象对象 * @param zLock 锁抽象对象
*/ */
default void unlock(ZLock zLock) throws Exception { default void unlock(ZLock zLock) throws Exception {
this.unlock(zLock.getLock()); if (zLock != null) {
this.unlock(zLock.getLock());
}
} }
} }
@@ -40,7 +40,6 @@ public class LockAspect {
@Around("@within(lock) || @annotation(lock)") @Around("@within(lock) || @annotation(lock)")
public Object aroundLock(ProceedingJoinPoint point, Lock lock) throws Throwable { public Object aroundLock(ProceedingJoinPoint point, Lock lock) throws Throwable {
Object lockObj = null;
if (lock == null) { if (lock == null) {
// 获取类上的注解 // 获取类上的注解
lock = point.getTarget().getClass().getDeclaredAnnotation(Lock.class); lock = point.getTarget().getClass().getDeclaredAnnotation(Lock.class);
@@ -59,6 +58,7 @@ public class LockAspect {
Object[] args = point.getArgs(); Object[] args = point.getArgs();
lockKey = getValBySpEL(lockKey, methodSignature, args); lockKey = getValBySpEL(lockKey, methodSignature, args);
} }
ZLock lockObj = null;
try { try {
//加锁 //加锁
if (lock.waitTime() > 0) { if (lock.waitTime() > 0) {