Concurrency issue in gml/xml parsing
------------------------------------

                 Key: GEOT-2615
                 URL: http://jira.codehaus.org/browse/GEOT-2615
             Project: GeoTools
          Issue Type: Bug
          Components: core xml
    Affects Versions: 2.5.5
            Reporter: Niklas Eklund


GML parsing with gtxml (2.5.5) intermittently fails in a multi-threaded 
environment with exceptions similar to:
java.lang.ArrayIndexOutOfBoundsException: 194
        at org.eclipse.emf.common.util.BasicEList.indexOf(BasicEList.java:373)
        at org.eclipse.emf.common.util.BasicEList.remove(BasicEList.java:866)
        at 
org.eclipse.emf.common.notify.impl.BasicNotifierImpl$EAdapterList.remove(BasicNotifierImpl.java:137)
        at 
org.geotools.xml.impl.SchemaIndexImpl.destroy(SchemaIndexImpl.java:97)
        at 
org.geotools.xml.impl.ParserHandler.endDocument(ParserHandler.java:603)
      ...

The exceptions change but are always in SchemaIndexImpl + BasicEList so this 
could either be a bug in emf or how emf classes are used by SchemaIndexImpl.

This code snippet triggers the error on my machine:

                final String gml = "<gml:Point srsName=\"EPSG:4326\" 
xmlns:gml=\"http://www.opengis.net/gml\";><gml:coordinates cs=\",\" 
decimal=\".\" ts=\" 
\">11.9119821266414,57.6756639706692</gml:coordinates></gml:Point>";
                final int tCount = 2;
                final int nIter = 1000;

                Thread[] threads = new Thread[tCount];
                for (int i = 0; i < tCount; ++i) {
                        Thread t = new Thread() {
                                @Override
                                public void run() {
                                        for (int i = 0; i < nIter; ++i) {
                                                try {
                                                        final Configuration 
configuration = new GMLConfiguration();
                                                        final Parser parser = 
new Parser(configuration);
                                                        parser.parse(new 
StringReader(gml));
                                                } catch (Throwable t) {
                                                        t.printStackTrace();
                                                }
                                        }
                                }
                        };
                        threads[i] = t;
                        t.start();
                }
                for (int i = 0; i < tCount; ++i) {
                        try {
                                threads[i].join();
                        } catch (InterruptedException e) {
                                e.printStackTrace();
                        }
                }

If the call to parser.parse is serialized/synchronized so that only one thread 
can parse at once, no errors seem to appear.

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

        

------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge  
This is your chance to win up to $100,000 in prizes! For a limited time, 
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize  
details at: http://p.sf.net/sfu/Challenge
_______________________________________________
Geotools-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-devel

Reply via email to