Skip to content

Commit 8cf8593

Browse files
authored
🎨 调整加锁与获取缓存的顺序
1 parent 4abffde commit 8cf8593

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/BaseWxMpServiceImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,10 +267,10 @@ public String getAccessToken(boolean forceRefresh) throws WxErrorException {
267267
boolean locked = false;
268268
try {
269269
do {
270-
locked = lock.tryLock(100, TimeUnit.MILLISECONDS);
271270
if (!forceRefresh && !this.getWxMpConfigStorage().isAccessTokenExpired()) {
272271
return this.getWxMpConfigStorage().getAccessToken();
273272
}
273+
locked = lock.tryLock(100, TimeUnit.MILLISECONDS);
274274
if (!locked && System.currentTimeMillis() > timeOutMillis) {
275275
throw new InterruptedException("获取accessToken超时:获取时间超时");
276276
}

0 commit comments

Comments
 (0)