smengcl commented on code in PR #10710:
URL: https://github.com/apache/ozone/pull/10710#discussion_r3557333760


##########
hadoop-ozone/httpfsgateway/src/main/java/org/apache/ozone/lib/service/instrumentation/InstrumentationService.java:
##########
@@ -308,23 +294,13 @@ static class VariableHolder<E> implements JSONAware, 
JSONStreamAware {
       this.var = var;
     }
 
-    @SuppressWarnings("unchecked")
-    private JSONObject getJSON() {
-      JSONObject json = new JSONObject();
+    @JsonValue
+    Map<String, Object> getJSON() {
+      Map<String, Object> json = new LinkedHashMap<>();
       json.put("value", var.getValue());
       return json;
     }

Review Comment:
   This is pre-existing behavior, not introduced by this change. On master the 
same values are produced during serialization: Timer/VariableHolder/Sampler 
implemented JSONAware/JSONStreamAware, and their 
toJSONString()/writeJSONString() called the identical getJSON() body 
(getValues(), var.getValue(), getRate()). This migration only swaps json-simple 
for Jackson and preserves that behavior; it does not alter these code paths or 
getSnapshot() locking. Hardening the publish-before-initialize window is a 
separate behavior change and is out of scope for this dependency swap. Leaving 
as-is here; happy to file a follow-up JIRA if desired.



##########
hadoop-ozone/httpfsgateway/src/main/java/org/apache/ozone/lib/service/instrumentation/InstrumentationService.java:
##########
@@ -362,23 +338,13 @@ void sample() {
           ((full) ? values.length : ((last == 0) ? 1 : last));
     }
 
-    @SuppressWarnings("unchecked")
-    private JSONObject getJSON() {
-      JSONObject json = new JSONObject();
+    @JsonValue
+    Map<String, Object> getJSON() {
+      Map<String, Object> json = new LinkedHashMap<>();
       json.put("sampler", getRate());
       json.put("size", (full) ? values.length : last);
       return json;
     }

Review Comment:
   This is pre-existing behavior, not introduced by this change. On master the 
same values are produced during serialization: Timer/VariableHolder/Sampler 
implemented JSONAware/JSONStreamAware, and their 
toJSONString()/writeJSONString() called the identical getJSON() body 
(getValues(), var.getValue(), getRate()). This migration only swaps json-simple 
for Jackson and preserves that behavior; it does not alter these code paths or 
getSnapshot() locking. Hardening the publish-before-initialize window is a 
separate behavior change and is out of scope for this dependency swap. Leaving 
as-is here; happy to file a follow-up JIRA if desired.



##########
hadoop-ozone/httpfsgateway/src/main/java/org/apache/ozone/lib/service/instrumentation/InstrumentationService.java:
##########
@@ -251,27 +247,17 @@ void addCron(Cron cron) {
       }
     }
 
-    @SuppressWarnings("unchecked")
-    private JSONObject getJSON() {
+    @JsonValue
+    Map<String, Object> getJSON() {
       long[] values = getValues();
-      JSONObject json = new JSONObject();
+      Map<String, Object> json = new LinkedHashMap<>();
       json.put("lastTotal", values[0]);

Review Comment:
   This is pre-existing behavior, not introduced by this change. On master the 
same values are produced during serialization: Timer/VariableHolder/Sampler 
implemented JSONAware/JSONStreamAware, and their 
toJSONString()/writeJSONString() called the identical getJSON() body 
(getValues(), var.getValue(), getRate()). This migration only swaps json-simple 
for Jackson and preserves that behavior; it does not alter these code paths or 
getSnapshot() locking. Hardening the publish-before-initialize window is a 
separate behavior change and is out of scope for this dependency swap. Leaving 
as-is here; happy to file a follow-up JIRA if desired.



##########
hadoop-ozone/httpfsgateway/src/main/java/org/apache/ozone/fs/http/server/FSOperations.java:
##########
@@ -374,17 +373,16 @@ private static Map<String, Object> 
quotaUsageToMap(QuotaUsage quotaUsage) {
    *
    * @return the JSON representation of the key-value pair.
    */
-  @SuppressWarnings("unchecked")
-  private static JSONObject toJSON(String name, Object value) {
-    JSONObject json = new JSONObject();
+  private static Map<String, Object> toJSON(String name, Object value) {

Review Comment:
   Fixed: the JsonAware reference was updated in 3214d75321c and the duplicated 
"with" removed in 05b051aacea.



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