🐛 修复小程序发送请求方法空指针异常问题

This commit is contained in:
GeXiangDong 2024-11-05 19:30:51 +08:00 committed by GitHub
parent 7b161b1abb
commit 9c6fca77e6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -343,12 +343,14 @@ public abstract class BaseWxMaServiceImpl<H, P> implements WxMaService, RequestH
public <R, T> R execute(RequestExecutor<R, T> executor, String uri, T data) public <R, T> R execute(RequestExecutor<R, T> executor, String uri, T data)
throws WxErrorException { throws WxErrorException {
String dataForLog; String dataForLog;
if (data instanceof String) { if (data == null) {
dataForLog = null;
} else if (data instanceof String) {
dataForLog = DataUtils.handleDataWithSecret((String) data); dataForLog = DataUtils.handleDataWithSecret((String) data);
} else { } else {
dataForLog = data.toString(); dataForLog = data.toString();
} }
return excuteWithRetry( return executeWithRetry(
(uriWithAccessToken) -> executor.execute(uriWithAccessToken, data, WxType.MiniApp), (uriWithAccessToken) -> executor.execute(uriWithAccessToken, data, WxType.MiniApp),
uri, uri,
dataForLog); dataForLog);
@ -362,7 +364,7 @@ public abstract class BaseWxMaServiceImpl<H, P> implements WxMaService, RequestH
String data) String data)
throws WxErrorException { throws WxErrorException {
String dataForLog = "Headers: " + headers.toString() + " Body: " + data; String dataForLog = "Headers: " + headers.toString() + " Body: " + data;
return excuteWithRetry( return executeWithRetry(
(uriWithAccessToken) -> executor.execute(uriWithAccessToken, headers, data, WxType.MiniApp), (uriWithAccessToken) -> executor.execute(uriWithAccessToken, headers, data, WxType.MiniApp),
uri, uri,
dataForLog); dataForLog);
@ -372,7 +374,7 @@ public abstract class BaseWxMaServiceImpl<H, P> implements WxMaService, RequestH
R execute(String urlWithAccessToken) throws IOException, WxErrorException; R execute(String urlWithAccessToken) throws IOException, WxErrorException;
} }
private <R, T> R excuteWithRetry(ExecutorAction<R> executor, String uri, String dataForLog) private <R, T> R executeWithRetry(ExecutorAction<R> executor, String uri, String dataForLog)
throws WxErrorException { throws WxErrorException {
int retryTimes = 0; int retryTimes = 0;
do { do {