From fc8d815d6ea47dc031acfe5182ae421fe137a0be Mon Sep 17 00:00:00 2001 From: Ripic Zhang <56013580+ylwind@users.noreply.github.com> Date: Sat, 2 Mar 2024 18:11:37 +0800 Subject: [PATCH] =?UTF-8?q?:art:=20=E5=A2=9E=E5=8A=A0=E5=8A=A0=E9=94=81?= =?UTF-8?q?=E7=9A=84=E8=B6=85=E6=97=B6=E6=97=B6=E9=97=B4=EF=BC=8C=E9=81=BF?= =?UTF-8?q?=E5=85=8D=E6=AD=BB=E5=BE=AA=E7=8E=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../me/chanjar/weixin/mp/api/impl/BaseWxMpServiceImpl.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/BaseWxMpServiceImpl.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/BaseWxMpServiceImpl.java index 901a6637b..a0cf9a200 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/BaseWxMpServiceImpl.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/BaseWxMpServiceImpl.java @@ -263,6 +263,7 @@ public abstract class BaseWxMpServiceImpl 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 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;