small JSON cleanup in ClusterNodeDetailsAPIServlet

Change-Id: If4a261d27b74934f122d9efbd5cde70efa6f9fd5
Reviewed-on: https://asterix-gerrit.ics.uci.edu/1426
Sonar-Qube: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
BAD: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Integration-Tests: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Ian Maxon <imaxon@apache.org>
diff --git a/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/servlet/ClusterNodeDetailsAPIServlet.java b/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/servlet/ClusterNodeDetailsAPIServlet.java
index 590e869..d737ad8 100644
--- a/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/servlet/ClusterNodeDetailsAPIServlet.java
+++ b/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/servlet/ClusterNodeDetailsAPIServlet.java
@@ -33,6 +33,7 @@
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
+import com.fasterxml.jackson.databind.JsonNode;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.fasterxml.jackson.databind.SerializationFeature;
 import org.apache.asterix.runtime.util.ClusterStateManager;
@@ -161,18 +162,21 @@
         for (String key : keys) {
             if (key.startsWith("gc-")) {
                 json.remove(key);
-            } else if (json.get(key) instanceof ArrayNode) {
-                final ArrayNode valueArray = (ArrayNode) json.get(key);
-                // fixup an index of -1 to the final element in the array (i.e. RRD_SIZE)
-                if (index == -1) {
-                    index = valueArray.size() - 1;
+            } else {
+                final JsonNode keyNode = json.get(key);
+                if (keyNode instanceof ArrayNode) {
+                    final ArrayNode valueArray = (ArrayNode) keyNode;
+                    // fixup an index of -1 to the final element in the array (i.e. RRD_SIZE)
+                    if (index == -1) {
+                        index = valueArray.size() - 1;
+                    }
+                    final JsonNode value = valueArray.get(index);
+                    json.remove(key);
+                    json.set(key.replaceAll("s$",""), value);
                 }
-                final Object value = valueArray.get(index);
-                json.remove(key);
-                json.putPOJO(key.replaceAll("s$",""), value);
             }
         }
-        List<ObjectNode> gcs = new ArrayList<>();
+        ArrayNode gcs = om.createArrayNode();
 
         for (int i = 0; i < gcNames.size(); i++) {
             ObjectNode gc = om.createObjectNode();
@@ -181,7 +185,7 @@
             gc.set("collection-count", ((ArrayNode)gcCollectionCounts.get(i)).get(index));
             gcs.add(gc);
         }
-        json.putPOJO("gcs", gcs);
+        json.set("gcs", gcs);
 
         return json;
     }