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

XML attributes parsed incorrectly if more than 7 attributes is used

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 6
    • xml
    • x86
    • windows_vista

      FULL PRODUCT VERSION :
      java version "1.6.0_01"
      Java(TM) SE Runtime Environment (build 1.6.0_01-b06)
      Java HotSpot(TM) Client VM (build 1.6.0_01-b06, mixed mode, sharing)


      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows [Version 6.0.6000]

      A DESCRIPTION OF THE PROBLEM :
      Parsing the following file:
      <?xml version="1.0"?>
      <input onchange="#{component.attributes['onchange']}"
      accesskey="#{component.attributes['accesskey']}"
      size="#{component.attributes['inputSize']}"
      style="#{component.attributes['inputStyle']}"
      class="#{component.attributes['inputClass']}"
      onselect="#{component.attributes['onselect']}"
      onfocus="#{component.attributes['onfocus']}" onblur="#{component.attributes['onblur']}"/>

      with the default parser returns onfocus attribute value as "#{component.attributes['onblur']}}"

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Save xml as test.jspx and run test code

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      onfocus="#{component.attributes['onfocus']}"
      is printed to the console
      ACTUAL -
      onfocus="#{component.attributes['onblur']}}"
      is printed

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(this.getClass().getResourceAsStream("test.jspx"));
      System.out.println(document.getDocumentElement()./*getChildNodes().item(1).*/getAttributes().getNamedItem("onfocus"));

      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      The problem seems to be in com.sun.org.apache.xerces.internal.impl.XMLScanner class, in getStringBuffer() method.

      There is the code there now:
                  XMLStringBuffer tmpObj = new XMLStringBuffer();
                  stringBufferCache.add(fStringBufferIndex, tmpObj);
                  return tmpObj;

      However I believe, the correct code should contain increment for fStringBufferIndex field:
                  XMLStringBuffer tmpObj = new XMLStringBuffer();
                  stringBufferCache.add(fStringBufferIndex, tmpObj);
                  fStringBufferIndex++l
                  return tmpObj;

      Manually incrementing the field in debugger solved the problem

            spericas Santiago Pericasgeertsen
            ndcosta Nelson Dcosta (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: