You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-dev@xerces.apache.org by "Lucian Holland (JIRA)" <xe...@xml.apache.org> on 2006/08/25 01:39:29 UTC

[jira] Created: (XERCESJ-1182) Race condition results in invalid event type being reported from XMLStreamReader

Race condition results in invalid event type being reported from XMLStreamReader
--------------------------------------------------------------------------------

                 Key: XERCESJ-1182
                 URL: http://issues.apache.org/jira/browse/XERCESJ-1182
             Project: Xerces2-J
          Issue Type: Bug
          Components: StAX
            Reporter: Lucian Holland
         Attachments: test.xml

The following code prints out "7" as it should do - the first event is a START_DOCUMENT event.

      SAXParserFactory factory = SAXParserFactory.newInstance();
      factory.setNamespaceAware(true);
      factory.setFeature("http://xml.org/sax/features/namespace-prefixes", true);
      SAXParser parser = factory.newSAXParser();       
      SAXSource source = new SAXSource(parser.getXMLReader(), new InputSource(FunctionalTestEventReading.class.getResourceAsStream("test.xml")));       
       XMLInputFactory inFac = new XMLInputFactoryImpl();
       XMLStreamReader reader = inFac.createXMLStreamReader(source);
       Thread.sleep(1000);
       System.err.println(reader.getEventType());

If I remove the Thread.sleep, however, it prints "0". It would seem like something is being kicked off in another thread, and not having time to get the first bit of the document parsed before the call to getEventType(). FWIW I'm running this under Eclipse in a simple test class with a main method - presumably this is somewhat dependent on machine speed/environment etc. to be able to reproduce. I have attached the xml file I'm testing with.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: j-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-dev-help@xerces.apache.org


[jira] Commented: (XERCESJ-1182) Race condition results in invalid event type being reported from XMLStreamReader

Posted by "Lucian Holland (JIRA)" <xe...@xml.apache.org>.
    [ http://issues.apache.org/jira/browse/XERCESJ-1182?page=comments#action_12438966 ] 
            
Lucian Holland commented on XERCESJ-1182:
-----------------------------------------

Thanks Michael - that works fine for me now.

> Race condition results in invalid event type being reported from XMLStreamReader
> --------------------------------------------------------------------------------
>
>                 Key: XERCESJ-1182
>                 URL: http://issues.apache.org/jira/browse/XERCESJ-1182
>             Project: Xerces2-J
>          Issue Type: Bug
>          Components: StAX
>            Reporter: Lucian Holland
>         Assigned To: Michael Glavassevich
>         Attachments: test.xml
>
>
> The following code prints out "7" as it should do - the first event is a START_DOCUMENT event.
>       SAXParserFactory factory = SAXParserFactory.newInstance();
>       factory.setNamespaceAware(true);
>       factory.setFeature("http://xml.org/sax/features/namespace-prefixes", true);
>       SAXParser parser = factory.newSAXParser();       
>       SAXSource source = new SAXSource(parser.getXMLReader(), new InputSource(FunctionalTestEventReading.class.getResourceAsStream("test.xml")));       
>        XMLInputFactory inFac = new XMLInputFactoryImpl();
>        XMLStreamReader reader = inFac.createXMLStreamReader(source);
>        Thread.sleep(1000);
>        System.err.println(reader.getEventType());
> If I remove the Thread.sleep, however, it prints "0". It would seem like something is being kicked off in another thread, and not having time to get the first bit of the document parsed before the call to getEventType(). FWIW I'm running this under Eclipse in a simple test class with a main method - presumably this is somewhat dependent on machine speed/environment etc. to be able to reproduce. I have attached the xml file I'm testing with.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: j-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-dev-help@xerces.apache.org


[jira] Assigned: (XERCESJ-1182) Race condition results in invalid event type being reported from XMLStreamReader

Posted by "Michael Glavassevich (JIRA)" <xe...@xml.apache.org>.
     [ http://issues.apache.org/jira/browse/XERCESJ-1182?page=all ]

Michael Glavassevich reassigned XERCESJ-1182:
---------------------------------------------

    Assignee: Michael Glavassevich

> Race condition results in invalid event type being reported from XMLStreamReader
> --------------------------------------------------------------------------------
>
>                 Key: XERCESJ-1182
>                 URL: http://issues.apache.org/jira/browse/XERCESJ-1182
>             Project: Xerces2-J
>          Issue Type: Bug
>          Components: StAX
>            Reporter: Lucian Holland
>         Assigned To: Michael Glavassevich
>         Attachments: test.xml
>
>
> The following code prints out "7" as it should do - the first event is a START_DOCUMENT event.
>       SAXParserFactory factory = SAXParserFactory.newInstance();
>       factory.setNamespaceAware(true);
>       factory.setFeature("http://xml.org/sax/features/namespace-prefixes", true);
>       SAXParser parser = factory.newSAXParser();       
>       SAXSource source = new SAXSource(parser.getXMLReader(), new InputSource(FunctionalTestEventReading.class.getResourceAsStream("test.xml")));       
>        XMLInputFactory inFac = new XMLInputFactoryImpl();
>        XMLStreamReader reader = inFac.createXMLStreamReader(source);
>        Thread.sleep(1000);
>        System.err.println(reader.getEventType());
> If I remove the Thread.sleep, however, it prints "0". It would seem like something is being kicked off in another thread, and not having time to get the first bit of the document parsed before the call to getEventType(). FWIW I'm running this under Eclipse in a simple test class with a main method - presumably this is somewhat dependent on machine speed/environment etc. to be able to reproduce. I have attached the xml file I'm testing with.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: j-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-dev-help@xerces.apache.org


[jira] Resolved: (XERCESJ-1182) Race condition results in invalid event type being reported from XMLStreamReader

Posted by "Michael Glavassevich (JIRA)" <xe...@xml.apache.org>.
     [ http://issues.apache.org/jira/browse/XERCESJ-1182?page=all ]

Michael Glavassevich resolved XERCESJ-1182.
-------------------------------------------

    Resolution: Fixed

There was a race condition which allowed the XMLStreamReader constructor to return before the start document event is produced. I've fixed that as well as significantly simplified the thread handling.

> Race condition results in invalid event type being reported from XMLStreamReader
> --------------------------------------------------------------------------------
>
>                 Key: XERCESJ-1182
>                 URL: http://issues.apache.org/jira/browse/XERCESJ-1182
>             Project: Xerces2-J
>          Issue Type: Bug
>          Components: StAX
>            Reporter: Lucian Holland
>         Assigned To: Michael Glavassevich
>         Attachments: test.xml
>
>
> The following code prints out "7" as it should do - the first event is a START_DOCUMENT event.
>       SAXParserFactory factory = SAXParserFactory.newInstance();
>       factory.setNamespaceAware(true);
>       factory.setFeature("http://xml.org/sax/features/namespace-prefixes", true);
>       SAXParser parser = factory.newSAXParser();       
>       SAXSource source = new SAXSource(parser.getXMLReader(), new InputSource(FunctionalTestEventReading.class.getResourceAsStream("test.xml")));       
>        XMLInputFactory inFac = new XMLInputFactoryImpl();
>        XMLStreamReader reader = inFac.createXMLStreamReader(source);
>        Thread.sleep(1000);
>        System.err.println(reader.getEventType());
> If I remove the Thread.sleep, however, it prints "0". It would seem like something is being kicked off in another thread, and not having time to get the first bit of the document parsed before the call to getEventType(). FWIW I'm running this under Eclipse in a simple test class with a main method - presumably this is somewhat dependent on machine speed/environment etc. to be able to reproduce. I have attached the xml file I'm testing with.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: j-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-dev-help@xerces.apache.org