🎨 增加加锁的超时时间,避免死循环

This commit is contained in:
Ripic Zhang 2024-03-02 18:11:37 +08:00 committed by GitHub
parent ad6ad003bc
commit fc8d815d6e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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;