com.sun.xml.internal.stream.XMLInputFactoryImpl getProperty - IAE for name=null

Bernd ecki at zusammenkunft.net
Mon Mar 2 17:30:23 UTC 2015


Hello,

I noticed that getProperty(String) will throw an IAE("Property not supported")
when null is specified. I think at least the message should be different
for the null case, as it is missleading (Not sure if NPE can be introduced
into this code now - the javadoc somehow allows it?).

http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/com/sun/xml/internal/stream/XMLInputFactoryImpl.java#210

Also the non-null case of a not-supported property does not name the
property which was requested. In my experience this is helpfull to have
those names in the reason message.

Both things combined are somewhat better handled in the setter code, so it
might be best to borrow it:

   if (name == null || !fPropertyManager.containsProperty(name) ) {
     throw new IllegalArgumentException("Property "+name+" is not
supported");
   }

(hasProperty could also be used, it returns false on null).

Gruss
Bernd



More information about the core-libs-dev mailing list