🎨 #2075 【公众号】修复设置最大重试次数为0时候异常处理错误的问题

Co-authored-by: luzhaoyuan <luzhaoyuan@ppdai.com>
This commit is contained in:
zainlu 2021-04-16 00:18:31 +08:00 committed by GitHub
parent 6f24f7b92e
commit fcc34c3913
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -331,15 +331,16 @@ public abstract class BaseWxMpServiceImpl<H, P> implements WxMpService, RequestH
try { try {
return this.executeInternal(executor, uri, data); return this.executeInternal(executor, uri, data);
} catch (WxErrorException e) { } catch (WxErrorException e) {
if (retryTimes + 1 > this.maxRetryTimes) {
log.warn("重试达到最大次数【{}】", maxRetryTimes);
//最后一次重试失败后直接抛出异常不再等待
throw new WxRuntimeException("微信服务端异常,超出重试次数");
}
WxError error = e.getError(); WxError error = e.getError();
// -1 系统繁忙, 1000ms后重试 // -1 系统繁忙, 1000ms后重试
if (error.getErrorCode() == -1) { if (error.getErrorCode() == -1) {
// 判断是否已经超了最大重试次数
if (retryTimes + 1 > this.maxRetryTimes) {
log.warn("重试达到最大次数【{}】", maxRetryTimes);
//最后一次重试失败后直接抛出异常不再等待
throw new WxRuntimeException("微信服务端异常,超出重试次数");
}
int sleepMillis = this.retrySleepMillis * (1 << retryTimes); int sleepMillis = this.retrySleepMillis * (1 << retryTimes);
try { try {
log.warn("微信系统繁忙,{} ms 后重试(第{}次)", sleepMillis, retryTimes + 1); log.warn("微信系统繁忙,{} ms 后重试(第{}次)", sleepMillis, retryTimes + 1);