[Fix-13820][alert] Fix bodyParams is empty get error log (#13821)

initialize an empty objectNode to save contentField.
This commit is contained in:
kingbabingge 2023-04-19 15:35:13 +08:00 committed by GitHub
parent dc4cd976c1
commit 81aa105ff6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 1 deletions

View File

@ -163,7 +163,10 @@ public final class HttpSender {
*/
private void setMsgInRequestBody(String msg) {
try {
ObjectNode objectNode = JSONUtils.parseObject(bodyParams);
ObjectNode objectNode = JSONUtils.createObjectNode();
if (StringUtils.isNotBlank(bodyParams)) {
objectNode = JSONUtils.parseObject(bodyParams);
}
// set msg content field
objectNode.put(contentField, msg);
StringEntity entity = new StringEntity(JSONUtils.toJsonString(objectNode), DEFAULT_CHARSET);