JDK-7191547 : XMLEventFactory.newFactory(String factoryId, ClassLoader loader) does not work as expected
  • Type: Bug
  • Component: xml
  • Sub-Component: javax.xml.stream
  • Affected Version: 7
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2012-08-15
  • Updated: 2013-07-16
  • Resolved: 2012-09-01
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 7 JDK 8
7u40 b06Fixed 8Fixed
Related Reports
Relates :  
Description
It looks XMLEventFactory.newFactory(String factoryId, ClassLoader classLoader) does not work as expected.

As java doc, factoryId should be "Name of the factory to find, same as a property name".
But actually it is treated as "property value". See below test code. I believe the bug is similar with CR 6756677, which treat factoryId as property value for XMLInputFactory.

It happens for latest build of 7u4, 7u6 and 8. 

Simple test code:
=========================
package javax.xml.stream;

import javax.xml.stream.* ;

public class Test{
public static void main(String[] args){
    System.setProperty("inputFac", "javax.xml.stream.MyInputFactory") ;
    System.setProperty("outputFac", "javax.xml.stream.MyOutputFactory") ;
    System.setProperty("eventFac", "javax.xml.stream.MyEventFactory") ;
   
    XMLInputFactory xif = XMLInputFactory.newFactory("inputFac", null);
    System.out.println(xif.getClass().getName()) ;


    XMLOutputFactory xof = XMLOutputFactory.newFactory("outputFac", null);
    System.out.println(xof.getClass().getName()) ;

    //work
        XMLEventFactory xef1 = XMLEventFactory.newFactory("javax.xml.stream.MyEventFactory", null);
        System.out.println(xef1.getClass().getName()) ;

    //do not work
        XMLEventFactory xef2 = XMLEventFactory.newFactory("eventFac", null);
        System.out.println(xef2.getClass().getName()) ;

}
}
==============

Output:
=============
javax.xml.stream.MyInputFactory
javax.xml.stream.MyOutputFactory
javax.xml.stream.MyEventFactory
Exception in thread "main" javax.xml.stream.FactoryConfigurationError: Provider eventFac not found
    at javax.xml.stream.XMLEventFactory.newFactory(XMLEventFactory.java:147)
    at javax.xml.stream.Test.main(Test.java:23)
Caused by: java.lang.ClassNotFoundException: eventFac
    at java.net.URLClassLoader$1.run(URLClassLoader.java:359)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:348)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:347)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
    at javax.xml.stream.FactoryFinder.getProviderClass(FactoryFinder.java:108)
    at javax.xml.stream.FactoryFinder.newInstance(FactoryFinder.java:143)
    at javax.xml.stream.XMLEventFactory.newFactory(XMLEventFactory.java:144)
    ... 1 more
=============

Comments
Verified with jdk7u40b33 promotion testing.
16-07-2013

Joe, you pushed your fix in August and so it's in 7uX. This is the code name for builds that come from the jdk7u repo : http://hg.openjdk.java.net/jdk7u/jdk7u/jaxp/rev/f9292d14967a RE are still using "7u14" as the update release number. We're going to switch over to 7u40 next week as a result of all the CPU releases. Communicaton and approval had to be sought to do that. Mail will be sent out to jdk_confidential alias about it shortly. Hope that answers your question. - Yes - it is in 7u14.. (b06) regards, Sean.
25-04-2013

EVALUATION Patch is now in tl repo.
17-08-2012

EVALUATION It looks like XMLEventFactory suffers the same issue as Input/Output factories.
15-08-2012