🎨 调整加锁与获取缓存的顺序

This commit is contained in:
Ripic Zhang
2024-03-13 23:26:39 +08:00
committed by GitHub
parent 4abffdea81
commit 8cf85933f0

View File

@ -267,10 +267,10 @@ public abstract class BaseWxMpServiceImpl<H, P> implements WxMpService, RequestH
boolean locked = false;
try {
do {
locked = lock.tryLock(100, TimeUnit.MILLISECONDS);
if (!forceRefresh && !this.getWxMpConfigStorage().isAccessTokenExpired()) {
return this.getWxMpConfigStorage().getAccessToken();
}
locked = lock.tryLock(100, TimeUnit.MILLISECONDS);
if (!locked && System.currentTimeMillis() > timeOutMillis) {
throw new InterruptedException("获取accessToken超时获取时间超时");
}