Skip to content

Commit 9c6fca7

Browse files
authored
🐛 修复小程序发送请求方法空指针异常问题
1 parent 7b161b1 commit 9c6fca7

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/BaseWxMaServiceImpl.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -343,12 +343,14 @@ public String upload(String url, CommonUploadParam param) throws WxErrorExceptio
343343
public <R, T> R execute(RequestExecutor<R, T> executor, String uri, T data)
344344
throws WxErrorException {
345345
String dataForLog;
346-
if (data instanceof String) {
346+
if (data == null) {
347+
dataForLog = null;
348+
} else if (data instanceof String) {
347349
dataForLog = DataUtils.handleDataWithSecret((String) data);
348350
} else {
349351
dataForLog = data.toString();
350352
}
351-
return excuteWithRetry(
353+
return executeWithRetry(
352354
(uriWithAccessToken) -> executor.execute(uriWithAccessToken, data, WxType.MiniApp),
353355
uri,
354356
dataForLog);
@@ -362,7 +364,7 @@ public WxMaApiResponse execute(
362364
String data)
363365
throws WxErrorException {
364366
String dataForLog = "Headers: " + headers.toString() + " Body: " + data;
365-
return excuteWithRetry(
367+
return executeWithRetry(
366368
(uriWithAccessToken) -> executor.execute(uriWithAccessToken, headers, data, WxType.MiniApp),
367369
uri,
368370
dataForLog);
@@ -372,7 +374,7 @@ private static interface ExecutorAction<R> {
372374
R execute(String urlWithAccessToken) throws IOException, WxErrorException;
373375
}
374376

375-
private <R, T> R excuteWithRetry(ExecutorAction<R> executor, String uri, String dataForLog)
377+
private <R, T> R executeWithRetry(ExecutorAction<R> executor, String uri, String dataForLog)
376378
throws WxErrorException {
377379
int retryTimes = 0;
378380
do {

0 commit comments

Comments
 (0)