binarywang/WxJava · warning · WxRuntimeException
微信服务端异常,超出重试次数
Error message
微信服务端异常,超出重试次数
What it means
Defensive fallback throw as WxRuntimeException after the retry do-while loop exits in BaseWxMaServiceImpl.executeWithRetry(). Under normal control flow this line is unreachable dead code: the catch-block throw at line 398 (error 171) always fires first, because retryTimes + 1 > maxRetryTimes becomes true before the loop condition can become false.
Source
Thrown at weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/BaseWxMaServiceImpl.java:422
WxError error = e.getError();
// -1 系统繁忙, 1000ms后重试
if (error.getErrorCode() == -1) {
int sleepMillis = this.retrySleepMillis * (1 << retryTimes);
try {
log.warn("微信系统繁忙,{} ms 后重试(第{}次)", sleepMillis, retryTimes + 1);
Thread.sleep(sleepMillis);
} catch (InterruptedException e1) {
Thread.currentThread().interrupt();
}
} else {
throw e;
}
}
} while (retryTimes++ < this.maxRetryTimes);
log.warn("重试达到最大次数【{}】", this.maxRetryTimes);
throw new WxRuntimeException("微信服务端异常,超出重试次数");
}
private <R, T> R executeInternal(
ExecutorAction<R> executor, String uri, String dataForLog, boolean doNotAutoRefreshToken)
throws WxErrorException {
if (uri.contains("access_token=")) {
throw new IllegalArgumentException("uri参数中不允许有access_token: " + uri);
}
String accessToken = getAccessToken(false);
String effectiveApiHostUrl = this.getWxMaConfig().getEffectiveApiHostUrl();
if (!WxMaConfig.DEFAULT_API_HOST_URL.equals(effectiveApiHostUrl)) {
uri = uri.replace(WxMaConfig.DEFAULT_API_HOST_URL, effectiveApiHostUrl);
}
String uriWithAccessToken =
uri + (uri.contains("?") ? "&" : "?") + "access_token=" + accessToken;View on GitHub (pinned to 1c43293a3c)
Solutions
- This throw is dead code under current logic — the catch-block throw at line 398 fires first; address error 171 instead
- If encountered in production, verify maxRetryTimes is non-negative and the retry loop has not been modified
Defensive patterns
Strategy: try-catch
Try / catch
// Same pattern as error 171 — this throw is dead code under normal flow // Unreachable; address error 171 instead
Prevention
- This throw is unreachable; focus on error 171's prevention tips
- Keep maxRetryTimes non-negative to avoid unexpected loop behavior
When it happens
Trigger: Unreachable in normal flow. Would only fire if the retry logic were refactored in a way that breaks the catch-block guard.
Common situations: This line should never execute. If it does, it indicates a logic regression or an extreme integer-overflow edge case in the retry loop.
Related errors
AI-assisted analysis of binarywang/WxJava@1c43293a3c (2026-08-14).
Data as JSON: /api/errors/245c659aac5cb7dc.
Report an issue: GitHub.