From 01f3644bbf523a5531632db879a551c3066d66ea Mon Sep 17 00:00:00 2001 From: luzhaoyuan Date: Tue, 13 Apr 2021 20:21:40 +0800 Subject: [PATCH] =?UTF-8?q?#2054=20=E3=80=90=E5=85=AC=E4=BC=97=E5=8F=B7?= =?UTF-8?q?=E3=80=91=E4=BF=AE=E5=A4=8D=E8=AE=BE=E7=BD=AE=E6=9C=80=E5=A4=A7?= =?UTF-8?q?=E9=87=8D=E8=AF=95=E6=AC=A1=E6=95=B0=E4=B8=BA0=E6=97=B6?= =?UTF-8?q?=E5=80=99=E5=BC=82=E5=B8=B8=E5=A4=84=E7=90=86=E9=94=99=E8=AF=AF?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../weixin/mp/api/impl/BaseWxMpServiceImpl.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/BaseWxMpServiceImpl.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/BaseWxMpServiceImpl.java index 932f130e13..fc0aceade6 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/BaseWxMpServiceImpl.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/BaseWxMpServiceImpl.java @@ -331,15 +331,16 @@ public T execute(RequestExecutor 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);