Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6730472

StAX has a typo in XMLOutputFactory.java that renders newInstance useless

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P3 P3
    • 1.4.0
    • 6
    • xml
    • x86
    • windows_xp

      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());

            joehw Joe Wang
            ndcosta Nelson Dcosta (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: