diff --git a/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-http/src/main/java/org/apache/dolphinscheduler/plugin/alert/http/HttpSender.java b/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-http/src/main/java/org/apache/dolphinscheduler/plugin/alert/http/HttpSender.java index 42f1474de47c..90280e802020 100644 --- a/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-http/src/main/java/org/apache/dolphinscheduler/plugin/alert/http/HttpSender.java +++ b/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-http/src/main/java/org/apache/dolphinscheduler/plugin/alert/http/HttpSender.java @@ -37,12 +37,14 @@ import lombok.SneakyThrows; import lombok.extern.slf4j.Slf4j; +import com.fasterxml.jackson.core.type.TypeReference; + @Slf4j public final class HttpSender { private Map headerParams; private OkHttpRequestHeaderContentType contentType; - private Map bodyParams; + private Map bodyParams; private HttpRequestMethod requestType; private int timeout; private String url; @@ -69,7 +71,8 @@ private void paramsValidator(Map paramsMap) { String bodyParamsString = paramsMap.get(HttpAlertConstants.NAME_BODY_PARAMS); if (StringUtils.isNotBlank(bodyParamsString)) { - bodyParams = JSONUtils.toMap(bodyParamsString); + bodyParams = JSONUtils.parseObject(bodyParamsString, new TypeReference>() { + }); if (bodyParams == null) { throw new IllegalArgumentException("bodyParams is not a valid json"); } @@ -215,8 +218,9 @@ private void setMsgInRequestBody(String msg) { } bodyParams.forEach((key, value) -> { - if (value.contains(HttpAlertConstants.MSG_PARAMS)) { - bodyParams.put(key, value.replace(HttpAlertConstants.MSG_PARAMS, msg)); + String valueOf = String.valueOf(value); + if (valueOf.contains(HttpAlertConstants.MSG_PARAMS)) { + bodyParams.put(key, valueOf.replace(HttpAlertConstants.MSG_PARAMS, msg)); } }); }