You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dolphinscheduler.apache.org by GitBox <gi...@apache.org> on 2022/07/21 11:08:24 UTC

[GitHub] [dolphinscheduler] tracehh commented on a diff in pull request #11033: [fix-10961][alert server]Change the content of alert to an array

tracehh commented on code in PR #11033:
URL: https://github.com/apache/dolphinscheduler/pull/11033#discussion_r926548179


##########
dolphinscheduler-alert/dolphinscheduler-alert-server/src/main/java/org/apache/dolphinscheduler/alert/AlertSenderService.java:
##########
@@ -93,6 +100,19 @@ public void send(List<Alert> alerts) {
                 continue;
             }
             AlertData alertData = new AlertData();
+
+            if (StringUtils.isNotEmpty(alert.getContent())) {
+                try {
+                    Object contentObject = new JSONTokener(alert.getContent()).nextValue();
+                    if (!(contentObject instanceof JSONArray)) {
+                        ObjectNode jsonNodes = JSONUtils.parseObject(alert.getContent());
+                        String content = JSONUtils.toJsonString(Collections.singletonList(jsonNodes));
+                        alert.setContent(content);
+                    }
+                } catch (JSONException e) {
+                    e.printStackTrace();

Review Comment:
   use  `logger.error("")` to log



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org