Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8358970

CounterMonitorMBean.getDerivedGaugeTimeStamp() JavaDoc incorrectly documents null

XMLWordPrintable

      A DESCRIPTION OF THE PROBLEM :
      The JavaDoc for javax.management.monitor.CounterMonitorMBean.getDerivedGaugeTimeStamp(ObjectName) method contains a documentation error. The method signature shows a return type of 'long' (primitive type), but the JavaDoc states it returns "null" for non-observed MBeans. Since primitive types cannot be null in Java, this is impossible and misleading.

      The actual implementation returns 0 (zero) for non-observed objects, not null as documented.


      ---------- BEGIN SOURCE ----------
      import java.lang.management.ManagementFactory;
      import javax.management.ObjectName;
      import javax.management.monitor.CounterMonitor;
      import javax.management.monitor.CounterMonitorMBean;

      public class CounterMonitorMBeanTest {
          public static void main(String[] args) throws Exception {
              CounterMonitorMBean monitor = new CounterMonitor();
              ManagementFactory.getPlatformMBeanServer()
                  .registerMBean(monitor, new ObjectName("test:type=Monitor"));
              
              // Query non-existent object
              ObjectName dummy = new ObjectName("dummy:type=dummy");
              long timestamp = monitor.getDerivedGaugeTimeStamp(dummy);
              
              System.out.println("Timestamp: " + timestamp); // Prints: 0
          }
      }
      ---------- END SOURCE ----------

            kevinw Kevin Walls
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: