Skip to content

Commit fcc34c3

Browse files
zainluluzhaoyuan
andauthored
🎨 #2075 【公众号】修复设置最大重试次数为0时候异常处理错误的问题
Co-authored-by: luzhaoyuan <luzhaoyuan@ppdai.com>
1 parent 6f24f7b commit fcc34c3

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

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

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -331,15 +331,16 @@ public <T, E> T execute(RequestExecutor<T, E> executor, String uri, E data) thro
331331
try {
332332
return this.executeInternal(executor, uri, data);
333333
} catch (WxErrorException e) {
334-
if (retryTimes + 1 > this.maxRetryTimes) {
335-
log.warn("重试达到最大次数【{}】", maxRetryTimes);
336-
//最后一次重试失败后,直接抛出异常,不再等待
337-
throw new WxRuntimeException("微信服务端异常,超出重试次数");
338-
}
339-
340334
WxError error = e.getError();
341335
// -1 系统繁忙, 1000ms后重试
342336
if (error.getErrorCode() == -1) {
337+
// 判断是否已经超了最大重试次数
338+
if (retryTimes + 1 > this.maxRetryTimes) {
339+
log.warn("重试达到最大次数【{}】", maxRetryTimes);
340+
//最后一次重试失败后,直接抛出异常,不再等待
341+
throw new WxRuntimeException("微信服务端异常,超出重试次数");
342+
}
343+
343344
int sleepMillis = this.retrySleepMillis * (1 << retryTimes);
344345
try {
345346
log.warn("微信系统繁忙,{} ms 后重试(第{}次)", sleepMillis, retryTimes + 1);

0 commit comments

Comments
 (0)