ArafatKhan2198 commented on code in PR #6500:
URL: https://github.com/apache/ozone/pull/6500#discussion_r1587276777


##########
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/keyvalue/KeyValueContainerMetadataInspector.java:
##########
@@ -181,55 +182,61 @@ public String process(ContainerData containerData, 
DatanodeStore store,
       return null;
     }
 
-    JsonObject containerJson = inspectContainer(kvData, store);
-    boolean correct = checkAndRepair(containerJson, kvData, store);
-
-    Gson gson = new GsonBuilder()
-        .setPrettyPrinting()
-        .serializeNulls()
-        .create();
-    String jsonReport = gson.toJson(containerJson);
-    if (log != null) {
-      if (correct) {
-        log.trace(jsonReport);
-      } else {
-        log.error(jsonReport);
+    ObjectNode containerJson = inspectContainer(kvData, store);
+    boolean correct = checkAndRepair(containerJson, kvData,
+        store);
+
+    ObjectMapper objectMapper = new ObjectMapper();
+    objectMapper.enable(
+        SerializationFeature.INDENT_OUTPUT);
+    String jsonReport = null;
+    try {
+      jsonReport = objectMapper.writeValueAsString(containerJson);

Review Comment:
   Thanks for the comment @devmadhuu 
   
   We are applying `objectMapper.enable(SerializationFeature.INDENT_OUTPUT);` 
to enable the `INDENT_OUTPUT` feature of the SerializationFeature class. This 
feature instructs the ObjectMapper to include indentation (line breaks and 
whitespace) when serializing Java objects to JSON. The shared objectMapper 
instance of JsonUtils does not have this serialization feature enabled because 
it is required in some places but not others. Since this ObjectMapper instance 
is shared among various classes, I thought it would be better to create a 
separate ObjectMapper instance for this class to enable the indentation feature.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to