File tree Expand file tree Collapse file tree 1 file changed +4
-0
lines changed
weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl Expand file tree Collapse file tree 1 file changed +4
-0
lines changed Original file line number Diff line number Diff line change @@ -263,13 +263,17 @@ public String getAccessToken(boolean forceRefresh) throws WxErrorException {
263263 }
264264
265265 Lock lock = this .getWxMpConfigStorage ().getAccessTokenLock ();
266+ long timeOutMillis = System .currentTimeMillis () + 3000 ;
266267 boolean locked = false ;
267268 try {
268269 do {
269270 locked = lock .tryLock (100 , TimeUnit .MILLISECONDS );
270271 if (!forceRefresh && !this .getWxMpConfigStorage ().isAccessTokenExpired ()) {
271272 return this .getWxMpConfigStorage ().getAccessToken ();
272273 }
274+ if (!locked && System .currentTimeMillis () > timeOutMillis ) {
275+ throw new InterruptedException ("获取accessToken超时:获取时间超时" );
276+ }
273277 } while (!locked );
274278
275279 String response ;
You can’t perform that action at this time.
0 commit comments