admin
2020-05-19 744594ef1a2f530fc3e86ea9dc48b62247f79420
fanli/src/main/java/com/yeshi/fanli/aspect/RequestSerializableAspect.java
@@ -1,6 +1,5 @@
package com.yeshi.fanli.aspect;
import java.io.IOException;
import java.io.PrintWriter;
import java.lang.reflect.Method;
import java.util.HashMap;
@@ -63,7 +62,7 @@
   }
   @Around("execution(public * com.yeshi.fanli.controller.client.*.*.*(..))")
   public Object requestSerializable(ProceedingJoinPoint joinPoint) throws IOException {
   public Object requestSerializable(ProceedingJoinPoint joinPoint) throws Throwable {
      Signature signature = joinPoint.getSignature();
      MethodSignature methodSignature = (MethodSignature) signature;
      Method targetMethod = methodSignature.getMethod();
@@ -97,14 +96,14 @@
                  cacheKey = "rs-" + StringUtil.Md5(cacheKey);
                  // jiedis原子性做拦截
                  Jedis jedis = jedisPool.getResource();
                  long threadId= Thread.currentThread().getId();
                  long threadId = Thread.currentThread().getId();
                  try {
                     Constant.waitingThreadSet.add(threadId);
                     String result = null;
                     long startTime = System.currentTimeMillis();
                     // 等待响应
                     while (StringUtil.isNullOrEmpty(result)) {
                        result = jedis.set(cacheKey, "1", new SetParams().nx().ex(30));
                        if (StringUtil.isNullOrEmpty(result)) {
                           try {
@@ -125,9 +124,6 @@
                     if (!StringUtil.isNullOrEmpty(result)) {
                        try {
                           return joinPoint.proceed();
                        } catch (Throwable e) {
                           e.printStackTrace();
                           LogHelper.errorDetailInfo(e);
                        } finally {
                           jedis.del(cacheKey);
                           Constant.waitingThreadSet.remove(Thread.currentThread().getId());
@@ -138,12 +134,7 @@
                  }
               }
            } catch (Exception e) {// 原子性保护出错
               try {
                  return joinPoint.proceed();
               } catch (Throwable e1) {
                  e.printStackTrace();
                  LogHelper.errorDetailInfo(e1);
               }
               return joinPoint.proceed();
            }
         }
@@ -157,7 +148,10 @@
         return joinPoint.proceed();
      } catch (Throwable e) {
         e.printStackTrace();
         LogHelper.errorDetailInfo(e);
         if (!Constant.IS_TEST)
            LogHelper.errorDetailInfo(e);
         else
            throw e;
      } finally {
      }
      return null;