A DESCRIPTION OF THE PROBLEM : The Javadoc for AttributeList.asList() states: “Throws: IllegalArgumentException – if this AttributeList contains an element that is not an Attribute.” A null reference is not an instance of javax.management.Attribute, therefore asList() should throw IllegalArgumentException when the underlying list contains null. REGRESSION : Last worked in version 17 ---------- BEGIN SOURCE ---------- import javax.management.Attribute; import javax.management.AttributeList; public class AttributeListNullBug { public static void main(String[] args) { AttributeList list = new AttributeList(); list.add(null); // insert invalid element try { list.asList(); // should fail System.out.println(null instanceof Attribute); // prints false throw new RuntimeException( "null is not an Attribute – asList() should have thrown IllegalArgumentException"); } catch (IllegalArgumentException e) { System.out.println("Caught expected IllegalArgumentException: " + e); } } } ---------- END SOURCE ----------
|