You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@eventmesh.apache.org by GitBox <gi...@apache.org> on 2022/12/01 00:57:41 UTC

[GitHub] [incubator-eventmesh] jonyangx commented on a diff in pull request #2318: [ISSUE #2317] Refactoring tool class JsonUtils

jonyangx commented on code in PR #2318:
URL: https://github.com/apache/incubator-eventmesh/pull/2318#discussion_r1036591398


##########
eventmesh-common/src/main/java/org/apache/eventmesh/common/utils/JsonUtils.java:
##########
@@ -42,29 +52,53 @@ public class JsonUtils {
      * @return json string
      */
     public static String serialize(Object obj) {
+        if (Objects.isNull(obj)) {
+            return null;
+        }
         try {
             return OBJECT_MAPPER.writeValueAsString(obj);
         } catch (JsonProcessingException e) {
             throw new JsonException("serialize to json error", e);
         }
     }
 
+    public static <T> byte[] serialize(String topic, Class<T> data) throws JsonProcessingException {

Review Comment:
   Suggest refactor throw exception .   Throw RuntimeException or CheckedException.



-- 
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: dev-unsubscribe@eventmesh.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: dev-help@eventmesh.apache.org