0 Replies Latest reply on Jun 16, 2004 12:42 PM by dhan

    JBoss 3.2.4 monitors ( ClassCastException )

    dhan Newbie


      I'm using jboss-3.2.4 and whenever I call getObservedObjects() on operation Monitor, it throws ClassCastException. Looking at the Monitor.java source code, it looks like there's a bug in getObservedObjects() operation.

      It basically creates a HashSet of keys(ObjectNames) and later try to cast to "ObservedObject" type.

      public ObjectName[] getObservedObjects()
      Set set = new HashSet(observedObjects.keySet());
      elementCount = set.size();
      ObjectName[] result = new ObjectName[set.size()];
      alreadyNotifieds = new int[set.size()];
      int count = 0;
      for (Iterator i = set.iterator(); i.hasNext();)
      ObservedObject object = (ObservedObject) i.next();
      result[count] = object.getObjectName();
      alreadyNotifieds[count++] = object.getAlreadyNotified();
      return result;

      Instead of "Set set = new HashSet(observedObjects.keySet());"
      I think it should be "Set set = new HashSet(observedObjects.values());"

      Otherwise, it would throw exception on
      ObservedObject object = (ObservedObject) i.next();
      every time since i.next() returns ObjectName

      Does anyone know if this problem is being addressed?