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

Bug in SAX2StAXEventWriter.java:334.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 1.4.0
    • 6
    • xml
    • 1.4
    • x86
    • windows_xp
    • Verified

      FULL PRODUCT VERSION :


      A DESCRIPTION OF THE PROBLEM :
        Bug in class SAX2StAXEventWriter. Version:
       * $Id: SAX2StAXEventWriter.java,v 1.3 2005/11/03 17:53:11 jeffsuttor Exp $
       * @(#)SAX2StAXEventWriter.java 1.7 06/01/27

      Wrong use of postfix '++' operator at line 334.
      in method protected void createStartEvents(Attributes attributes, Collection[] events);
      The line
      String uri = (String) namespaces.elementAt(i++); // postfix ++
      should be read as
      String uri = (String) namespaces.elementAt(++i); // prefix ++


      REPRODUCIBILITY :
      This bug can be reproduced always.

      CUSTOMER SUBMITTED WORKAROUND :
          protected void createStartEvents(Attributes attributes, Collection[] events) {

              .....

              // create namespaces
              if (namespaces != null) {

                  final int nDecls = namespaces.size();
                      for (int i = 0; i < nDecls; i++) {
                          final String prefix = (String) namespaces.elementAt(i);
                          String uri = (String) namespaces.elementAt(++i); // prefix ++
                      Namespace ns = createNamespace(prefix, uri);
                      if (nsMap == null) {

                          nsMap = new HashMap();

                      }
                      nsMap.put(prefix, ns);

                      
                  }

              }
          ....
      }

            nwalshsunw Norman Walsh (Inactive)
            ndcosta Nelson Dcosta (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: