JDK-6730472 : StAX has a typo in XMLOutputFactory.java that renders newInstance useless
  • Type: Bug
  • Component: xml
  • Sub-Component: jaxp
  • Affected Version: 6
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2008-07-28
  • Updated: 2012-06-09
  • Resolved: 2009-09-02
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.
Other
1.4.0Resolved
Related Reports
Duplicate :  
Description
FULL PRODUCT VERSION :
java version "1.6.0_07"
Java(TM) SE Runtime Environment (build 1.6.0_07-b06)
Java HotSpot(TM) Client VM (build 10.0-b23, mixed mode, sharing)

ADDITIONAL OS VERSION INFORMATION :
All - this is a simple typo with the wrong type of factory.
Specifically tested on:
Microsoft Windows XP [Version 5.1.2600]
Linux gringo.phoenix-int.com 2.6.20-17-generic #2 SMP Mon Jun 9 22:08:13 UTC 2008 i686 GNU/Linux

A DESCRIPTION OF THE PROBLEM :
The StAX implementation included with java includes a typo bug in which the newInstance function under XMLOutputFactory.java returns a type XMLInputFactory instead of XMLOutputFactory.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Use the newInstance function (2 parameters) on a XMLOutputFactory.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Error and fail to build
ACTUAL -
Error and fail to build

ERROR MESSAGES/STACK TRACES THAT OCCUR :
incompatible types
found   : javax.xml.stream.XMLInputFactory
required: javax.xml.stream.XMLOutputFactory

REPRODUCIBILITY :
This bug can be reproduced always.

CUSTOMER SUBMITTED WORKAROUND :
  Patch:

diff -Naur old/XMLOutputFactory.java new/XMLOutputFactory.java
--- old/XMLOutputFactory.java	2008-07-24 08:29:01.640625000 -0400
+++ new/XMLOutputFactory.java	2008-07-24 08:33:49.562500000 -0400
@@ -109,12 +109,12 @@
    * @return the factory implementation
    * @throws FactoryConfigurationError if an instance of this factory cannot be loaded
    */
-  public static XMLInputFactory newInstance(String factoryId,
+  public static XMLOutputFactory newInstance(String factoryId,
           ClassLoader classLoader)
           throws FactoryConfigurationError {
       try {
           //do not fallback if given classloader can't find the class, throw exception
-          return (XMLInputFactory) FactoryFinder.newInstance(factoryId, classLoader, false);
+          return (XMLOutputFactory) FactoryFinder.newInstance(factoryId, classLoader, false);
       } catch (FactoryFinder.ConfigurationError e) {
           throw new FactoryConfigurationError(e.getException(),
                   e.getMessage());

Comments
EVALUATION This is an API change and must be done with a JSR review. See 6861589.
02-09-2009