mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2025-08-25 01:14:36 +08:00
🐛 修复代码
This commit is contained in:
parent
d752c48dc8
commit
c175a31c45
@ -3,6 +3,8 @@ package me.chanjar.weixin.common.util.locks;
|
|||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.concurrent.locks.Condition;
|
import java.util.concurrent.locks.Condition;
|
||||||
import java.util.concurrent.locks.Lock;
|
import java.util.concurrent.locks.Lock;
|
||||||
|
|
||||||
|
import com.github.jedis.lock.JedisLock;
|
||||||
import redis.clients.jedis.Jedis;
|
import redis.clients.jedis.Jedis;
|
||||||
import redis.clients.util.Pool;
|
import redis.clients.util.Pool;
|
||||||
|
|
||||||
|
@ -23,8 +23,8 @@ import org.slf4j.LoggerFactory;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.locks.Lock;
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import java.util.concurrent.locks.Lock;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author <a href="https://github.com/007gzs">007</a>
|
* @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 = this.getWxOpenConfigStorage().getComponentAccessTokenLock();
|
||||||
lock.lock();
|
lock.lock();
|
||||||
try {
|
try {
|
||||||
if (StringUtils.equals(componentAccessToken, this.getWxOpenConfigStorage().getComponentAccessToken()){
|
if (StringUtils.equals(componentAccessToken, this.getWxOpenConfigStorage().getComponentAccessToken())) {
|
||||||
this.getWxOpenConfigStorage().expireComponentAccessToken();
|
this.getWxOpenConfigStorage().expireComponentAccessToken();
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
this.getWxOpenConfigStorage().expireComponentAccessToken();
|
this.getWxOpenConfigStorage().expireComponentAccessToken();
|
||||||
}finally {
|
} finally {
|
||||||
lock.unlock();
|
lock.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -202,12 +202,12 @@ public class WxOpenComponentServiceImpl implements WxOpenComponentService {
|
|||||||
Lock lock = this.getWxOpenConfigStorage().getComponentAccessTokenLock();
|
Lock lock = this.getWxOpenConfigStorage().getComponentAccessTokenLock();
|
||||||
lock.lock();
|
lock.lock();
|
||||||
try {
|
try {
|
||||||
if (StringUtils.equals(componentAccessToken, this.getWxOpenConfigStorage().getComponentAccessToken()){
|
if (StringUtils.equals(componentAccessToken, this.getWxOpenConfigStorage().getComponentAccessToken())) {
|
||||||
this.getWxOpenConfigStorage().expireComponentAccessToken();
|
this.getWxOpenConfigStorage().expireComponentAccessToken();
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
this.getWxOpenConfigStorage().expireComponentAccessToken();
|
this.getWxOpenConfigStorage().expireComponentAccessToken();
|
||||||
}finally {
|
} finally {
|
||||||
lock.unlock();
|
lock.unlock();
|
||||||
}
|
}
|
||||||
if (this.getWxOpenConfigStorage().autoRefreshToken()) {
|
if (this.getWxOpenConfigStorage().autoRefreshToken()) {
|
||||||
@ -379,13 +379,13 @@ public class WxOpenComponentServiceImpl implements WxOpenComponentService {
|
|||||||
@Override
|
@Override
|
||||||
public String getAuthorizerAccessToken(String appId, boolean forceRefresh) throws WxErrorException {
|
public String getAuthorizerAccessToken(String appId, boolean forceRefresh) throws WxErrorException {
|
||||||
WxOpenConfigStorage config = getWxOpenConfigStorage();
|
WxOpenConfigStorage config = getWxOpenConfigStorage();
|
||||||
if (!config.isAuthorizerAccessTokenExpired(appId) && !forceRefresh){
|
if (!config.isAuthorizerAccessTokenExpired(appId) && !forceRefresh) {
|
||||||
return config.getAuthorizerAccessToken(appId);
|
return config.getAuthorizerAccessToken(appId);
|
||||||
}
|
}
|
||||||
Lock lock = config.getWxMpConfigStorage(appId).getAccessTokenLock();
|
Lock lock = config.getWxMpConfigStorage(appId).getAccessTokenLock();
|
||||||
lock.lock();
|
lock.lock();
|
||||||
try{
|
try {
|
||||||
if (!config.isAuthorizerAccessTokenExpired(appId) && !forceRefresh){
|
if (!config.isAuthorizerAccessTokenExpired(appId) && !forceRefresh) {
|
||||||
return config.getAuthorizerAccessToken(appId);
|
return config.getAuthorizerAccessToken(appId);
|
||||||
}
|
}
|
||||||
JsonObject jsonObject = new JsonObject();
|
JsonObject jsonObject = new JsonObject();
|
||||||
@ -397,7 +397,7 @@ public class WxOpenComponentServiceImpl implements WxOpenComponentService {
|
|||||||
WxOpenAuthorizerAccessToken wxOpenAuthorizerAccessToken = WxOpenAuthorizerAccessToken.fromJson(responseContent);
|
WxOpenAuthorizerAccessToken wxOpenAuthorizerAccessToken = WxOpenAuthorizerAccessToken.fromJson(responseContent);
|
||||||
config.updateAuthorizerAccessToken(appId, wxOpenAuthorizerAccessToken);
|
config.updateAuthorizerAccessToken(appId, wxOpenAuthorizerAccessToken);
|
||||||
return config.getAuthorizerAccessToken(appId);
|
return config.getAuthorizerAccessToken(appId);
|
||||||
}finally {
|
} finally {
|
||||||
lock.unlock();
|
lock.unlock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user