Skip to content

Commit 33b13b1

Browse files
committed
🎨 #1591 给部分请求方法导致无限递归调用的代码增加日志,方便排查问题
1 parent 2797bd6 commit 33b13b1

File tree

5 files changed

+8
-1
lines changed

5 files changed

+8
-1
lines changed

Diff for: weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/BaseWxCpServiceImpl.java

+1
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,7 @@ protected <T, E> T executeInternal(RequestExecutor<T, E> executor, String uri, E
283283
// 强制设置wxCpConfigStorage它的access token过期了,这样在下一次请求里就会刷新access token
284284
this.configStorage.expireAccessToken();
285285
if (this.getWxCpConfigStorage().autoRefreshToken()) {
286+
log.warn("即将重新获取新的access_token,错误代码:{},错误信息:{}", error.getErrorCode(), error.getErrorMsg());
286287
return this.execute(executor, uri, data);
287288
}
288289
}

Diff for: weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/BaseWxCpTpServiceImpl.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import lombok.extern.slf4j.Slf4j;
77
import me.chanjar.weixin.common.enums.WxType;
88
import me.chanjar.weixin.common.bean.WxAccessToken;
9+
import me.chanjar.weixin.common.error.WxCpErrorMsgEnum;
910
import me.chanjar.weixin.common.error.WxError;
1011
import me.chanjar.weixin.common.error.WxErrorException;
1112
import me.chanjar.weixin.common.util.DataUtils;
@@ -222,10 +223,11 @@ protected <T, E> T executeInternal(RequestExecutor<T, E> executor, String uri, E
222223
* 发生以下情况时尝试刷新suite_access_token
223224
* 42009 suite_access_token已过期
224225
*/
225-
if (error.getErrorCode() == 42009) {
226+
if (error.getErrorCode() == WxCpErrorMsgEnum.CODE_42009.getCode()) {
226227
// 强制设置wxCpTpConfigStorage它的suite access token过期了,这样在下一次请求里就会刷新suite access token
227228
this.configStorage.expireSuiteAccessToken();
228229
if (this.getWxCpTpConfigStorage().autoRefreshToken()) {
230+
log.warn("即将重新获取新的access_token,错误代码:{},错误信息:{}", error.getErrorCode(), error.getErrorMsg());
229231
return this.execute(executor, uri, data);
230232
}
231233
}

Diff for: weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/BaseWxMaServiceImpl.java

+1
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,7 @@ private <T, E> T executeInternal(RequestExecutor<T, E> executor, String uri, E d
255255
lock.unlock();
256256
}
257257
if (this.getWxMaConfig().autoRefreshToken()) {
258+
log.warn("即将重新获取新的access_token,错误代码:{},错误信息:{}", error.getErrorCode(), error.getErrorMsg());
258259
return this.execute(executor, uri, data);
259260
}
260261
}

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

+1
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,7 @@ protected <T, E> T executeInternal(RequestExecutor<T, E> executor, String uri, E
372372
lock.unlock();
373373
}
374374
if (this.getWxMpConfigStorage().autoRefreshToken()) {
375+
log.warn("即将重新获取新的access_token,错误代码:{},错误信息:{}", error.getErrorCode(), error.getErrorMsg());
375376
return this.execute(executor, uri, data);
376377
}
377378
}

Diff for: weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenComponentServiceImpl.java

+2
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ public String post(String uri, String postData, String accessTokenKey) throws Wx
161161
}
162162

163163
if (this.getWxOpenConfigStorage().autoRefreshToken()) {
164+
log.warn("即将重新获取新的access_token,错误代码:{},错误信息:{}", error.getErrorCode(), error.getErrorMsg());
164165
return this.post(uri, postData, accessTokenKey);
165166
}
166167
}
@@ -198,6 +199,7 @@ public String get(String uri, String accessTokenKey) throws WxErrorException {
198199
lock.unlock();
199200
}
200201
if (this.getWxOpenConfigStorage().autoRefreshToken()) {
202+
log.warn("即将重新获取新的access_token,错误代码:{},错误信息:{}", error.getErrorCode(), error.getErrorMsg());
201203
return this.get(uri, accessTokenKey);
202204
}
203205
}

0 commit comments

Comments
 (0)