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


##########
hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/scm/container/common/helpers/DeletedBlocksTransactionInfoWrapper.java:
##########
@@ -39,6 +39,13 @@ public DeletedBlocksTransactionInfoWrapper(long txID, long 
containerID,
     this.count = count;
   }
 
+  DeletedBlocksTransactionInfoWrapper() {

Review Comment:
   Thanks a lot for the comment @szetszwo The reason why I included the default 
constructor is because in case if its not there then 
`TestDeletedBlocksTxnShell` will thrown the following error :- 
   ```
   java.io.IOException: 
com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot construct 
instance of 
`org.apache.hadoop.hdds.scm.container.common.helpers.DeletedBlocksTransactionInfoWrapper`
 (no Creators, like default constructor, exist): cannot deserialize from Object 
value (no delegate- or property-based Creator)
    at [Source: REDACTED (`StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION` 
disabled); line: 2, column: 3] (through reference chain: java.lang.Object[][0])
   ```
   
   Which aims to to indicate that Jackson, is unable to deserialize an instance 
of `DeletedBlocksTransactionInfoWrapper` because it lacks a **default 
constructor**. Jackson requires a default (no-argument) constructor to create 
instances of a class during deserialization.
   
   To resolve this issue, we have added a default constructor to the 
`DeletedBlocksTransactionInfoWrapper`



##########
hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/server/JsonUtils.java:
##########
@@ -103,14 +102,15 @@ public static JsonNode readTree(String content) throws 
IOException {
     return MAPPER.readTree(content);
   }
 
-  public static List<HashMap<String, Object>> readTreeAsListOfMaps(String json)
+  /**
+   * Reads JSON content from a Reader and deserializes it into an array of the
+   * specified type.
+   */
+  public static <T> T[] readArrayFromReader(Reader reader, Class<T[]> 
valueType)
       throws IOException {
-    return MAPPER.readValue(json,
-        new TypeReference<List<HashMap<String, Object>>>() {
-        });
+    return MAPPER.readValue(reader, valueType);
   }

Review Comment:
   Done!



-- 
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