You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-users@xmlgraphics.apache.org by Frederik Santens <fr...@pandora.be> on 2004/10/04 20:25:13 UTC

java.util.ConcurrentModificationException

Hi,
 
We have a svg application that  updates a svg canvas via its
updatemanager. The changes are triggered by a poller that polls for
database changes. This poller runs in a separte thread. Every 2 seconds,
a maximum of 400 svg parts can get updated. However we receive the
following exception:
 
 
java.util.ConcurrentModificationException
            at
java.util.HashMap$HashIterator.nextEntry(HashMap.java:782)
            at java.util.HashMap$KeyIterator.next(HashMap.java:818)
            at
org.apache.batik.gvt.UpdateTracker.getDirtyAreas(UpdateTracker.java:99)
            at org.apache.batik.bridge.UpdateManager.repaint(Unknown
Source)
            at
org.apache.batik.bridge.UpdateManager$UpdateManagerRunHander.runnableInv
oked(Unknown Source)
            at
org.apache.batik.util.RunnableQueue.runnableInvoked(RunnableQueue.java:4
73)
            at
org.apache.batik.util.RunnableQueue.run(RunnableQueue.java:217)
            at java.lang.Thread.run(Thread.java:534)
 
Any Idea’s?
 
Thx,
Frederik

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.769 / Virus Database: 516 - Release Date: 9/24/2004
 

Re: java.util.ConcurrentModificationException

Posted by Stan Dickerson <en...@energycontrolsystems.com>.
I think a ConcurrentModificationException is caused when one thread is
in the process of iterating a collection (e.g. a Vector) and another
thread modifies the collection by adding or removing elements.

I don't know if this is the best but here is my method for updating the
runnableQueue:

public synchronized void runnableQueueInvoke(Runnable runnable, boolean
wait)
{
    try
    {
        if (runnableQueue == null)
        {
            UpdateManager updateManager = svgCanvas.getUpdateManager();
            if (updateManager != null)
            {
                if (updateManager.isRunning())
                {
                    runnableQueue =
updateManager.getUpdateRunnableQueue();
                    if (runnableQueue.getQueueState() !=
                            RunnableQueue.RUNNING)
                        runnableQueue = null;
                }
                updateManager = null;
            }
        }
        if (runnableQueue != null)
        {
            if (runnableQueue.getQueueState() == RunnableQueue.RUNNING)
            {
                if (wait)
                    runnableQueue.invokeAndWait(runnable);
                else
                    runnableQueue.invokeLater(runnable);
            }
            else
                runnableQueue = null;
        }
    }
    catch (Exception ex) {
        System.out.println("runnableQueueInvoke:"+ex);
    }
}

Any comments are welcome.

Stan Dickerson


On Mon, 2004-10-04 at 14:25, Frederik Santens wrote:
> Hi,
> 
>  
> 
> We have a svg application that  updates a svg canvas via its
> updatemanager. The changes are triggered by a poller that polls for
> database changes. This poller runs in a separte thread. Every 2
> seconds, a maximum of 400 svg parts can get updated. However we
> receive the following exception:
> 
>  
> 
>  
> 
> java.util.ConcurrentModificationException
> 
>             at
> java.util.HashMap$HashIterator.nextEntry(HashMap.java:782)
> 
>             at java.util.HashMap$KeyIterator.next(HashMap.java:818)
> 
>             at
> org.apache.batik.gvt.UpdateTracker.getDirtyAreas(UpdateTracker.java:99)
> 
>             at org.apache.batik.bridge.UpdateManager.repaint(Unknown
> Source)
> 
>             at
> org.apache.batik.bridge.UpdateManager$UpdateManagerRunHander.runnableInvoked(Unknown Source)
> 
>             at
> org.apache.batik.util.RunnableQueue.runnableInvoked(RunnableQueue.java:473)
> 
>             at
> org.apache.batik.util.RunnableQueue.run(RunnableQueue.java:217)
> 
>             at java.lang.Thread.run(Thread.java:534)
> 
>  
> 
> Any Idea’s?
> 
>  
> 
> Thx,
> 
> Frederik
> 
> 
> ---
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.769 / Virus Database: 516 - Release Date: 9/24/2004
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org


Re: java.util.ConcurrentModificationException

Posted by Thomas DeWeese <Th...@Kodak.com>.
Hi Frederik,

Frederik Santens wrote:

> We have a svg application that  updates a svg canvas via its 
> updatemanager. The changes are triggered by a poller that polls for 
> database changes. This poller runs in a separte thread. Every 2 seconds, 
> a maximum of 400 svg parts can get updated. However we receive the 
> following exception:

    This error has almost always been caused by modifying the SVG
DOM outside of the update manager thread.  The one case where it
wasn't was caused by modifying the viewing transform of the SVG,
this normally is associated with resizing the window, although
I could probably also be caused 'programatically'.

    So if you are doing something to regularly adjust the view
in the Canvas you might want to update to the most recent
version in CVS.  Otherwise I would look really closely at my
code and make sure you aren't touching the DOM outside of the
UpdateManager's runnable queue.

> 
>  
> 
>  
> 
> java.util.ConcurrentModificationException
> 
>             at java.util.HashMap$HashIterator.nextEntry(HashMap.java:782)
> 
>             at java.util.HashMap$KeyIterator.next(HashMap.java:818)
> 
>             at 
> org.apache.batik.gvt.UpdateTracker.getDirtyAreas(UpdateTracker.java:99)
> 
>             at org.apache.batik.bridge.UpdateManager.repaint(Unknown 
> Source)
> 
>             at 
> org.apache.batik.bridge.UpdateManager$UpdateManagerRunHander.runnableInvoked(Unknown 
> Source)
> 
>             at 
> org.apache.batik.util.RunnableQueue.runnableInvoked(RunnableQueue.java:473)
> 
>             at 
> org.apache.batik.util.RunnableQueue.run(RunnableQueue.java:217)
> 
>             at java.lang.Thread.run(Thread.java:534)
> 
>  
> 
> Any Idea’s?
> 
>  
> 
> Thx,
> 
> Frederik
> 
> 
> ---
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.769 / Virus Database: 516 - Release Date: 9/24/2004
> 



---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org