mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2025-06-28 13:16:19 +08:00
🎨 增加加锁的超时时间,避免死循环
This commit is contained in:
parent
ad6ad003bc
commit
fc8d815d6e
@ -263,6 +263,7 @@ public abstract class BaseWxMpServiceImpl<H, P> implements WxMpService, RequestH
|
||||
}
|
||||
|
||||
Lock lock = this.getWxMpConfigStorage().getAccessTokenLock();
|
||||
long timeOutMillis = System.currentTimeMillis() + 3000;
|
||||
boolean locked = false;
|
||||
try {
|
||||
do {
|
||||
@ -270,6 +271,9 @@ public abstract class BaseWxMpServiceImpl<H, P> implements WxMpService, RequestH
|
||||
if (!forceRefresh && !this.getWxMpConfigStorage().isAccessTokenExpired()) {
|
||||
return this.getWxMpConfigStorage().getAccessToken();
|
||||
}
|
||||
if (!locked && System.currentTimeMillis() > timeOutMillis) {
|
||||
throw new InterruptedException("获取accessToken超时:获取时间超时");
|
||||
}
|
||||
} while (!locked);
|
||||
|
||||
String response;
|
||||
|
Loading…
Reference in New Issue
Block a user