JDK-8165197 : xmldecoder method is throwing error while parsing xml
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.beans
  • Affected Version: 7
  • Priority: P3
  • Status: Closed
  • Resolution: Not an Issue
  • Submitted: 2016-09-01
  • Updated: 2016-12-26
  • Resolved: 2016-12-12
Related Reports
Relates :  
Description
Since JDK7 XMLDecoder can throw java.lang.IllegalArgumentException for unsupported attributes:
Caused by: java.lang.IllegalArgumentException: Unsupported attribute: xmlns:af 
     at com.sun.beans.decoder.ElementHandler.addAttribute(ElementHandler.java:142) 
     at com.sun.beans.decoder.JavaElementHandler.addAttribute(JavaElementHandler.java: 78) 
     at com.sun.beans.decoder.DocumentHandler.startElement(DocumentHandler.java:294) 
     ... 164 more 
Comments
This problem looks like improper usage of XMLEncoder/XMLDecoder classes. XMLEncoder documentation [1] states that "The XMLDecoder class is used to read XML documents created using the XMLEncoder". In some cases,applications can process the XML content generated by XMLEncoder through XML identity transformer that inserts additional "xmlns" attributes into <java> element that violates the XML syntax defined in XMLEncoder javadoc [1]. This problem is not reproducible on JDK6 due to XMLDecoder API enhancements made in JDK7 [2] that introduced additional checks for the names of supported attributes ("id" in this particular case). It looks more like that 6u (not 7u) has a bug in not catching non XMLEncoded XML content - which got fixed in 7u [1] https://docs.oracle.com/javase/7/docs/api/java/beans/XMLEncoder.html [2] https://bugs.openjdk.java.net/browse/JDK-4864117
26-12-2016