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

com.sun.org.apache.xerces.internal.impl.XMLStreamFilterImpl has incorrect behaviour of hasNext()

XMLWordPrintable

    • b78
    • generic
    • generic
    • Verified

      JCK : JCK6.0 b17
      J2SE : FAIL - mustang b69
      Platform[s] : FAIL - seems to be all
      switch/Mode : FAIL - default


      com.sun.org.apache.xerces.internal.impl.XMLStreamFilterImpl has incorrect behaviour of hasNext() (result is always true if called more then once)

      the following set of tests:

      api/javax_xml/stream/AllSimpleTypesFilterTest.html#AllSimpleTypesFilterTest[testStreamEquals]
      api/javax_xml/stream/DefaultNamespaceFilterTest.html#DefaultNamespaceFilterTest[testStreamEquals]
      api/javax_xml/stream/NameFilterTest.html#NameFilterTest[testStreamEquals]
      api/javax_xml/stream/TypeFilterTest.html#TypeFilterTest[testStreamEquals]

      fail due to incorrect realization of com.sun.org.apache.xerces.internal.impl.XMLStreamFilterImpl.hasNext().

      the following example hangs on mustang:

      import javax.xml.stream.XMLStreamReader;
      import javax.xml.stream.XMLEventReader;
      import javax.xml.stream.StreamFilter;
      import javax.xml.stream.EventFilter;
      import javax.xml.stream.XMLInputFactory;
      import javax.xml.stream.XMLStreamException;
      import javax.xml.stream.events.XMLEvent;


      public class sample{

      public static void main(String[] args){

      try{
        XMLInputFactory factory = XMLInputFactory.newInstance();
        TypeFilter f;
        java.io.File input = new java.io.File(".", "sample.xml");;

          factory = XMLInputFactory.newInstance();
          f = new TypeFilter();
          f.addType(XMLEvent.START_ELEMENT);
          f.addType(XMLEvent.END_ELEMENT);
          f.addType(XMLEvent.PROCESSING_INSTRUCTION);
          f.addType(XMLEvent.CHARACTERS);
          f.addType(XMLEvent.COMMENT);
          f.addType(XMLEvent.SPACE);
          f.addType(XMLEvent.START_DOCUMENT);
          f.addType(XMLEvent.END_DOCUMENT);

            XMLStreamReader r1 =
              factory.createFilteredReader(factory.createXMLStreamReader(new java.io.FileReader(input)), (StreamFilter)f);


          while(r1.hasNext()) {
      r1.next();

      System.out.println("first: R1.hasNext:"+r1.hasNext());
      System.out.println("second: R1.hasNext:"+r1.hasNext());
      System.out.println("third: R1.hasNext:"+r1.hasNext());
           }

      System.out.println(r1);


      }catch (Exception e){
      e.printStackTrace();
      }
      }

      }


      with output like this:

      first: R1.hasNext:false
      second: R1.hasNext:true
      third: R1.hasNext:true

      All necessary files to reproduce this bug are attached.

            sreddysunw Sunitha Reddy (Inactive)
            pastepan Pavel Stepanov (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: