Sfoglia il codice sorgente

:bug: 修复代码

Binary Wang 5 anni fa
parent
commit
c175a31c45

+ 2 - 0
weixin-java-common/src/main/java/me/chanjar/weixin/common/util/locks/JedisDistributedLock.java

@@ -3,6 +3,8 @@ package me.chanjar.weixin.common.util.locks;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.locks.Condition;
 import java.util.concurrent.locks.Lock;
+
+import com.github.jedis.lock.JedisLock;
 import redis.clients.jedis.Jedis;
 import redis.clients.util.Pool;
 

+ 9 - 9
weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenComponentServiceImpl.java

@@ -23,8 +23,8 @@ import org.slf4j.LoggerFactory;
 
 import java.util.List;
 import java.util.Map;
-import java.util.concurrent.locks.Lock;
 import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.locks.Lock;
 
 /**
  * @author <a href="https://github.com/007gzs">007</a>
@@ -158,12 +158,12 @@ public class WxOpenComponentServiceImpl implements WxOpenComponentService {
         Lock lock = this.getWxOpenConfigStorage().getComponentAccessTokenLock();
         lock.lock();
         try {
-          if (StringUtils.equals(componentAccessToken, this.getWxOpenConfigStorage().getComponentAccessToken()){
+          if (StringUtils.equals(componentAccessToken, this.getWxOpenConfigStorage().getComponentAccessToken())) {
             this.getWxOpenConfigStorage().expireComponentAccessToken();
           }
         } catch (Exception ex) {
           this.getWxOpenConfigStorage().expireComponentAccessToken();
-        }finally {
+        } finally {
           lock.unlock();
         }
 
@@ -202,12 +202,12 @@ public class WxOpenComponentServiceImpl implements WxOpenComponentService {
         Lock lock = this.getWxOpenConfigStorage().getComponentAccessTokenLock();
         lock.lock();
         try {
-          if (StringUtils.equals(componentAccessToken, this.getWxOpenConfigStorage().getComponentAccessToken()){
+          if (StringUtils.equals(componentAccessToken, this.getWxOpenConfigStorage().getComponentAccessToken())) {
             this.getWxOpenConfigStorage().expireComponentAccessToken();
           }
         } catch (Exception ex) {
           this.getWxOpenConfigStorage().expireComponentAccessToken();
-        }finally {
+        } finally {
           lock.unlock();
         }
         if (this.getWxOpenConfigStorage().autoRefreshToken()) {
@@ -379,13 +379,13 @@ public class WxOpenComponentServiceImpl implements WxOpenComponentService {
   @Override
   public String getAuthorizerAccessToken(String appId, boolean forceRefresh) throws WxErrorException {
     WxOpenConfigStorage config = getWxOpenConfigStorage();
-    if (!config.isAuthorizerAccessTokenExpired(appId) && !forceRefresh){
+    if (!config.isAuthorizerAccessTokenExpired(appId) && !forceRefresh) {
       return config.getAuthorizerAccessToken(appId);
     }
     Lock lock = config.getWxMpConfigStorage(appId).getAccessTokenLock();
     lock.lock();
-    try{
-      if (!config.isAuthorizerAccessTokenExpired(appId) && !forceRefresh){
+    try {
+      if (!config.isAuthorizerAccessTokenExpired(appId) && !forceRefresh) {
         return config.getAuthorizerAccessToken(appId);
       }
       JsonObject jsonObject = new JsonObject();
@@ -397,7 +397,7 @@ public class WxOpenComponentServiceImpl implements WxOpenComponentService {
       WxOpenAuthorizerAccessToken wxOpenAuthorizerAccessToken = WxOpenAuthorizerAccessToken.fromJson(responseContent);
       config.updateAuthorizerAccessToken(appId, wxOpenAuthorizerAccessToken);
       return config.getAuthorizerAccessToken(appId);
-    }finally {
+    } finally {
       lock.unlock();
     }
   }