[ http://jira.jboss.com/jira/browse/JBJMX-3?page=history ]

Scott M Stark reassigned JBJMX-3:
---------------------------------

    Assign To: Scott M Stark  (was: Adrian Brock)

I added a simple extension to the 4.0 branch 
org.jboss.test.jbossmx.compliance.monitor.BasicTestCase to access the 
ObservedObjects in the testCounterSimpleNotification, and this now fails with a 
ClassCastException:

  public void testCounterSimpleNotification()
    throws Exception
  {
    try
    {
      monitored = new CounterSupport();
      observedObject = new ObjectName("Monitor:type=CounterSupport");
      observedAttribute = "Value";
      startCounterService(false, 0, 0, 10);
      ObjectName[] observed = (ObjectName[]) 
server.getAttribute(this.monitorName,
         "ObservedObjects");

      setAttribute(null, 0);
      setAttribute(new Integer(10), 1);
      setAttribute(new Integer(9), 1);
      setAttribute(new Integer(10), 2);
    }
    finally
    {
      stopMonitorService();
    }
  }

Caused by: java.lang.ClassCastException
   at javax.management.monitor.Monitor.getObservedObjects(Monitor.java:164)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at 
org.jboss.mx.interceptor.AttributeDispatcher.invoke(AttributeDispatcher.java:81)
   ... 23 more


> Fix ClassCastException in 
> javax.management.monitor.Monitor.getObservedObjects()
> -------------------------------------------------------------------------------
>
>          Key: JBJMX-3
>          URL: http://jira.jboss.com/jira/browse/JBJMX-3
>      Project: JBoss JMX
>         Type: Patch
>  Environment: At least from Jboss 3.2.5. Still in HEAD.
>     Reporter: Christopher Day
>     Assignee: Scott M Stark

>
>
> 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()];

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://jira.jboss.com/jira/secure/Administrators.jspa
-
If you want more information on JIRA, or have a bug to report see:
   http://www.atlassian.com/software/jira



-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now. 
http://productguide.itmanagersjournal.com/
_______________________________________________
JBoss-Development mailing list
JBoss-Development@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to