[jbossseam-issues] [JBoss JIRA] Commented: (JBSEAM-2086) ConcurrentModificationException in Pages.wildcardViewIds

Przemyslaw Jaskierski (JIRA) jira-events at lists.jboss.org
Sun Dec 9 09:39:51 EST 2007


    [ http://jira.jboss.com/jira/browse/JBSEAM-2086?page=comments#action_12391226 ] 
            
Przemyslaw Jaskierski commented on JBSEAM-2086:
-----------------------------------------------

I've looked into this closer, forgive my previous assumptions on the reason why wildcardViewIds changes in time. Please, read on.

Suggestion from the forum thread will not fix anything, it's a common synchronized collection misunderstanding. If you do not want to redesign Pages.java and only rely on synchronization, you have to synchronize() on the wildcardViewIds itself. Collections.synchronizedSortedSet and all synchronized collections guarantees synchronization on individual method calls only.

But here we have: 

233: for (String wildcard: wildcardViewIds) {  //iteration over collection
    /*
    and in this iteration there is a flow path possible that results in calling  private void parse(Element element, String viewId)
    and in line 989 you are concurrently adding to wildcardViewIds from inside of the for-each loop.
    */
}

A first-shot solution for this would be to add synchronized(wildcardViewIds){} around this foreach and around wildcardViewIds.add(viewId) in line 989.
But these code blocks are accessed concurrently and very often AFAIK, and using such agressive synchronization triggers "code smells" alert in case of
highly concurrent code blocks... A total redesign/rewrite of wildcards processing could be the best way here, but read on, please.

After some tests

1. Forum solution doesn't work here, as expected.
2. My first-shot solution with synchronized() blocks works and makes the exception gone.
3. JMeter performance test doesn't show any drop in performance, but my test environment/hardware is limited and I would definitively follow the "this code smells" alert 
    and suggest to look at this problem in a broader scope.

I've spotted no similar flaws on other collections in this class. 

Hope I helped.

> ConcurrentModificationException in Pages.wildcardViewIds
> --------------------------------------------------------
>
>                 Key: JBSEAM-2086
>                 URL: http://jira.jboss.com/jira/browse/JBSEAM-2086
>             Project: JBoss Seam
>          Issue Type: Bug
>          Components: Core
>    Affects Versions: 2.0.0.CR2
>            Reporter: Pete Muir
>             Fix For: 2.0.1.GA
>
>


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

        



More information about the seam-issues mailing list