Преглед изворни кода

update 优化 RepeatSubmitAspect.KEY_CACHE 清理不彻底

疯狂的狮子Li пре 3 месеци
родитељ
комит
3904d80329

+ 6 - 5
ruoyi-common/ruoyi-common-idempotent/src/main/java/org/dromara/common/idempotent/aspectj/RepeatSubmitAspect.java

@@ -12,6 +12,7 @@ import org.aspectj.lang.annotation.AfterThrowing;
 import org.aspectj.lang.annotation.Aspect;
 import org.aspectj.lang.annotation.Before;
 import org.dromara.common.core.constant.GlobalConstants;
+import org.dromara.common.core.constant.HttpStatus;
 import org.dromara.common.core.domain.R;
 import org.dromara.common.core.exception.ServiceException;
 import org.dromara.common.core.utils.MessageUtils;
@@ -76,16 +77,16 @@ public class RepeatSubmitAspect {
      */
     @AfterReturning(pointcut = "@annotation(repeatSubmit)", returning = "jsonResult")
     public void doAfterReturning(JoinPoint joinPoint, RepeatSubmit repeatSubmit, Object jsonResult) {
-        if (jsonResult instanceof R<?> r) {
-            try {
+        try {
+            if (jsonResult instanceof R<?> r) {
                 // 成功则不删除redis数据 保证在有效时间内无法重复提交
-                if (r.getCode() == R.SUCCESS) {
+                if (r.getCode() == HttpStatus.SUCCESS) {
                     return;
                 }
                 RedisUtils.deleteObject(KEY_CACHE.get());
-            } finally {
-                KEY_CACHE.remove();
             }
+        } finally {
+            KEY_CACHE.remove();
         }
     }