|
Quick Lists
|
|
Bug ID:
|
6675768
|
|
Votes
|
0
|
|
Synopsis
|
java.util.NoSuchElementException thrown in RequiredModelMBean when tracing enabled
|
|
Category
|
jmx:classes
|
|
Reported Against
|
|
|
Release Fixed
|
7(b26)
|
|
State
|
10-Fix Delivered,
bug
|
|
Priority:
|
4-Low
|
|
Related Bugs
|
6471865
|
|
Submit Date
|
14-MAR-2008
|
|
Description
|
The class javax.management.modelmbean.RequiredModelMBean handles a listener in the method addAttributeChangeNotificationListener. The listener has a Vector which is be populated through the provided attributes either through the config file or command line. When no attributes are provided the Vector is empty.
RequiredModelMBean.java has an unguarded tracing path on line 2223, which directly accesses the attribute vector to retrieve the element information:
if (tracing());
trace(ftag, "Set attribute change filter to " +
((currFilter.getEnabledAttributes()).firstElement()).toString());
This leads to a java.util.NoSuchElementException being thrown if their are no attributes.
To reproduce the issue, run the testcase (below) with the following command line option:
-Djava.util.logging.config.file=logging.properties
Where logging.properties is a file containing the following line:
javax.management.level=FINEST
You then get the following output when running the testcase:
c:\>java -Djava.util.logging.config.file=logging.properties MBeanTester
java.util.NoSuchElementException
at java.util.Vector.firstElement(Vector.java:442)
at javax.management.modelmbean.RequiredModelMBean.addAttributeChangeNotificationListener(RequiredModelMBean.java:2255)
at MBeanTester.main(MBeanTester.java:15)
Testcase Source:
--------------------------------------------------------------------
import javax.management.modelmbean.RequiredModelMBean;
import javax.management.*;
public class MBeanTester implements NotificationListener {
public void handleNotification(Notification n,Object o) {
System.out.println("Notification"+n);
}
public static void main(String[] args) {
Object o = new Object();
NotificationListener nl = new MBeanTester();
try {
RequiredModelMBean mbean = new RequiredModelMBean();
mbean.addAttributeChangeNotificationListener(nl,null,o);
} catch (Exception e) {
e.printStackTrace();
}
}
}
--------------------------------------------------------------------
Posted Date : 2008-03-14 21:23:30.0
|
|
Work Around
|
N/A
|
|
Evaluation
|
This should happen rarely in practice. To trigger the problem, you must (a) have logging enabled, (b) call the unusual method RequiredModelMBean.addAttributeChangeNotificationListener, (c) with a null argument (to signify any attribute), (d) on an MBean that has no attributes. Nevertheless the fix is straightforward and we should certainly apply it.
Posted Date : 2008-03-19 12:13:23.0
|
|
Comments
|
PLEASE NOTE: JDK6 is formerly known as Project Mustang
|
|
|
 |