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

ManagementFactory.getPlatformMBeanServer() does not return

XMLWordPrintable

      ADDITIONAL SYSTEM INFORMATION :
      NAME="Amazon Linux"
      VERSION="2"

      openjdk version "1.8.0_272"
      OpenJDK Runtime Environment (build 1.8.0_272-b10)
      OpenJDK 64-Bit Server VM (build 25.272-b10, mixed mode)



      A DESCRIPTION OF THE PROBLEM :
      We retrieve the MBean server by making the below call.

      private static MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();

      After the above statement control never reached to the next line.

      Example:
      static {
          try {
            logger.info("static block started");
            MBeanServer mbs1 = ManagementFactory.getPlatformMBeanServer();
            logger.info("static block completed {}", mbs1);
          } catch (Exception e) {
            logger.error("static errror", e);
            e.printStackTrace();
          }
        }

      Comment "static block completed" is never printed and neither any exception is thrown.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. In any test application in class define static member variable
          private static MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();

      2. In a different method
          register any mbean to the server
          add log statement after the mbean register

      3. Invoke the method from any external class.




      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The MBean should be successfully registered and the log statement should be printed.
      ACTUAL -
      The log statement is never registered.

      FREQUENCY : always


            Unassigned Unassigned
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: