johann Sorel ha scritto: > hello, > > I am having more and more problems with having multiple modifications on > a Datastore. > > Actually I am stuck when I try to render and edit geometry. > The fact is I can't find a way be be sure the datastore is not used > be trying to edit/render. > > I spend a complete afternoon trying to avoid each one to acces the datastore > at the same time, I have no control and no way to know if the renderer is > using it or not. > > I tryed "synchronized" stuff, or even using a kind of "lock" (with a boolean > at true if used) > ... > but no... It works a few seconds and randomly it raise a > java.util.ConcurrentModificationException. > > > I can't finish the editableMap2D will this problem isn't solved. > > In this case I only have two possible objects using the datastore... but in > the futur there is high probability that some more will try to access a > datastore at the same time. > > > the full error : > java.util.ConcurrentModificationException > at > java.util.LinkedHashMap$LinkedHashIterator.nextEntry(LinkedHashMap.java:373) > at java.util.LinkedHashMap$ValueIterator.next(LinkedHashMap.java:388) > at > org.geotools.data.memory.MemoryDataStore$1.next(MemoryDataStore.java:382) > at > org.geotools.data.FilteringFeatureReader.hasNext(FilteringFeatureReader.java:125) > at > org.geotools.data.store.FeatureReaderIterator.hasNext(FeatureReaderIterator.java:44) > at > org.geotools.renderer.lite.StreamingRenderer.processStylers(StreamingRenderer.java:1596) > at > org.geotools.renderer.lite.StreamingRenderer.paint(StreamingRenderer.java:647) > at > org.geotools.renderer.shape.ShapefileRenderer.renderWithStreamingRenderer(ShapefileRenderer.java:1454) > at > org.geotools.renderer.shape.ShapefileRenderer.paint(ShapefileRenderer.java:1325) > at > org.geotools.renderer.shape.ShapefileRenderer.paint(ShapefileRenderer.java:266) > at > org.geotools.renderer.shape.ShapefileRenderer.paint(ShapefileRenderer.java:1479) > at > org.geotools.gui.swing.map.map2d.strategy.SingleBufferedImageStrategy.createBufferImage(SingleBufferedImageStrategy.java:299) > at > org.geotools.gui.swing.map.map2d.strategy.SingleBufferedImageStrategy$DrawingThread.run(SingleBufferedImageStrategy.java:459)
This kind of error occurrs for a number of things occurring togheter: * the memory data store using a LinkedHashMap to store features (hashmap to provide very fast fid based access, linked to preserve insertion order) * renderer scanning thru the map using an iterator over the original LinkedHashMap * editor changing the contents of the above collection while the renderer is working on it Ways to solve this problem. Quick ideas are: * have FeatureIterator objects take a snapshot of the LinkedHashMap contents and work on top of it. Not a deep copy btw, a shallow one that just give the iterator its own collection that no one else will touch * change from LinkedHashMap to something else that won't throw a ConcurrentModificationException... could not find any. Yet, if ArrayList was used, a loop like: for(int i = 0; i < size(); i++) features.get(i) would not throw an exception One last thing... why are you using a MemoryDataStore? The last time I tried it, it was very slow, significantly slower than shapefiles for example, this is due to cloning, the same iterator that scans thru the features collection will clone them so that any change to the returned feature won't affect the datastore internals. Cheers Andrea ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ Geotools-devel mailing list Geotools-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/geotools-devel