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

ThreadMXBean.getThreadInfo([]): unexpected MBeanException for invalid ID

    Details

      Description

      Name: viR10068 Date: 06/07/2004


      The description for the methods ThreadMXBean.getThreadInfo(long[] ids) says:
      "If a thread of a given ID is not alive or does not exist, the corresponding
      element in the returned array will contain null."

      But jdk1.5.0-b54 throws the unexpected MBeanException for the invalid ID
      instead of returning array of null. Note, this bug is reproduced under
      MBean server only, without MBean the method works as expected.

      The RI should be fixed.

      The following JCK tests fail due to this bug:
      api/java_lang/management/ThreadMXBean/index.html#infoTrdMBean_MB[infoThreadMXBean0107]
      api/java_lang/management/ThreadMXBean/index.html#infoTrdMBean_MB[infoThreadMXBean0118]

      The test source:
      --------------------------- B.java -----------------------------------
      package B;
      import java.io.PrintStream;
      import java.lang.management.*;
      import javax.management.*;
      import javax.management.openmbean.*;


      class B {

          public static void main(String argv[]) {
              final ObjectName objName;
              try {
                  objName = new ObjectName("java.lang:type=Threading");
              } catch (MalformedObjectNameException me) {
                  System.out.println("Ups: " + me);
                  return;
              }

              MBeanServer mbs;
              String [] signArr = {"[J"};
              long [] idArr = {new Thread().getId()};
      // long [] idArr = {Thread.currentThread().getId()};
              Object [] paramArr = {idArr};

              System.out.println("result is " +
      ManagementFactory.getThreadMXBean().getThreadInfo(idArr)[0]);
              try {
                  mbs = ManagementFactory.getPlatformMBeanServer();
                  mbs.invoke(objName, "getThreadInfo", paramArr, signArr);
              } catch (JMException ex) {
                  System.out.println("Unexpected exception: " + ex);
                  return;
              }
              System.out.println("OKAY");
          }
      }
      -------------------------------------------------------------------------

      Execution log:
      % jdk1.5.0-b54/solaris-sparc/bin/javac -source 1.5 -target 1.5 -d . B.java &&
      jdk1.5.0-b54/solaris-sparc/bin/java -Xfuture -showversion B.B
      java version "1.5.0-beta3"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta3-b54)
      Java HotSpot(TM) Client VM (build 1.5.0-beta3-b54, mixed mode)

      result is null
      Unexpected exception: javax.management.MBeanException: Exception thrown when invoking
      operation getThreadInfo
      %

      ======================================================================

        Attachments

          Activity

            People

            • Assignee:
              mchung Mandy Chung
              Reporter:
              vivsunw Viv Viv (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Imported:
                Indexed: