Uploaded image for project: 'Application Server 3  4  5 and 6'
  1. Application Server 3 4 5 and 6
  2. JBAS-1716

Fix ClassCastException in javax.management.monitor.Monitor.getObservedObjects()

    XMLWordPrintable

Details

    Description

      When trying to access a StringMonitor from jmx-console, I get a ClassCastException from javax.management.monitor.Monitor.getObservedObjects(). This is because the method incorrectly iterates over the keys of the observedObjects HashMap, rather than the values. The Exception is raised when the iterator.next() is cast to an ObservedObject, since the keys are ObjectNames. The following patch fixes the problem.

      — Monitor.java 2004-12-22 16:57:52.207142400 -0800
      +++ /cygdrive/c/jboss-3.2.5-src/jmx/src/main/javax/management/monitor/Monitor.java 2004-01-02 13:56:54.000000000 -0800
      @@ -181,7 +181,7 @@

      public ObjectName[] getObservedObjects()
      {

      • Set set = new HashSet(observedObjects.values());
        + Set set = new HashSet(observedObjects.keySet());
        elementCount = set.size();
        ObjectName[] result = new ObjectName[set.size()];
        alreadyNotifieds = new int[set.size()];

      Attachments

        Activity

          People

            starksm64 Scott Stark (Inactive)
            ctday_jira Christopher Day (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: