Skip to content

Commit

Permalink
🎨 #2075 【公众号】修复设置最大重试次数为0时候异常处理错误的问题
Browse files Browse the repository at this point in the history
Co-authored-by: luzhaoyuan <luzhaoyuan@ppdai.com>
  • Loading branch information
zainlu and luzhaoyuan authored Apr 15, 2021
1 parent 6f24f7b commit fcc34c3
Showing 1 changed file with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -331,15 +331,16 @@ public <T, E> T execute(RequestExecutor<T, E> executor, String uri, E data) thro
try {
return this.executeInternal(executor, uri, data);
} catch (WxErrorException e) {
if (retryTimes + 1 > this.maxRetryTimes) {
log.warn("重试达到最大次数【{}】", maxRetryTimes);
//最后一次重试失败后,直接抛出异常,不再等待
throw new WxRuntimeException("微信服务端异常,超出重试次数");
}

WxError error = e.getError();
// -1 系统繁忙, 1000ms后重试
if (error.getErrorCode() == -1) {
// 判断是否已经超了最大重试次数
if (retryTimes + 1 > this.maxRetryTimes) {
log.warn("重试达到最大次数【{}】", maxRetryTimes);
//最后一次重试失败后,直接抛出异常,不再等待
throw new WxRuntimeException("微信服务端异常,超出重试次数");
}

int sleepMillis = this.retrySleepMillis * (1 << retryTimes);
try {
log.warn("微信系统繁忙,{} ms 后重试(第{}次)", sleepMillis, retryTimes + 1);
Expand Down

0 comments on commit fcc34c3

Please sign in to comment.