Few bug fixes jmx-rest-api
authorhb
Thu, 28 Dec 2017 20:34:32 +0530
branchjmx-rest-api
changeset 56001 95c0323f0c1a
parent 56000 054866e5113c
child 56002 60ab3b595a8e
Few bug fixes
src/java.management.rest/share/classes/com/oracle/jmx/remote/rest/http/MBeanCollectionResource.java
src/java.management.rest/share/classes/com/oracle/jmx/remote/rest/http/MBeanResource.java
src/java.management.rest/share/classes/com/oracle/jmx/remote/rest/http/MBeanServerResource.java
--- a/src/java.management.rest/share/classes/com/oracle/jmx/remote/rest/http/MBeanCollectionResource.java	Thu Dec 28 20:05:03 2017 +0530
+++ b/src/java.management.rest/share/classes/com/oracle/jmx/remote/rest/http/MBeanCollectionResource.java	Thu Dec 28 20:34:32 2017 +0530
@@ -62,7 +62,7 @@
             // Return true for MXbean
             Descriptor desc = mInfo.getDescriptor();
             String isMxBean = (String) desc.getFieldValue("mxbean");
-            if (isMxBean.equalsIgnoreCase("true"))
+            if (isMxBean != null && isMxBean.equalsIgnoreCase("true"))
                 return true;
 
             // Check attribute types
@@ -188,7 +188,7 @@
 
             Map<String, String> properties = new HashMap<>();
 
-            properties.put("mbeanCount", Integer.toString(filteredMBeans.size()));
+            properties.put("mbeanCount", Integer.toString(allowedMbeans.size()));
 
             JSONMapper typeMapper1 = JSONMappingFactory.INSTANCE.getTypeMapper(items);
             JSONMapper typeMapper2 = JSONMappingFactory.INSTANCE.getTypeMapper(properties);
--- a/src/java.management.rest/share/classes/com/oracle/jmx/remote/rest/http/MBeanResource.java	Thu Dec 28 20:05:03 2017 +0530
+++ b/src/java.management.rest/share/classes/com/oracle/jmx/remote/rest/http/MBeanResource.java	Thu Dec 28 20:34:32 2017 +0530
@@ -508,7 +508,7 @@
         }
 
         AttributeList attrVals = mBeanServer.getAttributes(objectName, attrs);
-        List<String> missingAttrs = Arrays.asList(attrs);
+        List<String> missingAttrs = new ArrayList<>(Arrays.asList(attrs));
         attrVals.asList().forEach(a -> {
             missingAttrs.remove(a.getName());
             result.put(a.getName(), a.getValue());
--- a/src/java.management.rest/share/classes/com/oracle/jmx/remote/rest/http/MBeanServerResource.java	Thu Dec 28 20:05:03 2017 +0530
+++ b/src/java.management.rest/share/classes/com/oracle/jmx/remote/rest/http/MBeanServerResource.java	Thu Dec 28 20:34:32 2017 +0530
@@ -168,6 +168,7 @@
         }
     }
 
+    @Override
     public synchronized void start() {
         if (!started) {
             httpContext = httpServer.createContext("/jmx/servers/" + contextStr, this);
@@ -294,8 +295,8 @@
         private long timeout = Long.MAX_VALUE;   // Timeout in seconds
 
         private class TimeStampedValue<T> {
-            private T value;
-            private long insertTimeStamp;
+            private final T value;
+            private final long insertTimeStamp;
 
             TimeStampedValue(T value) {
                 this.value = value;