You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by "Daniel Stoch (JIRA)" <ji...@apache.org> on 2014/06/16 12:39:02 UTC
[jira] [Created] (WICKET-5619) ConcurrentModificationException may
occur when calling EventBus.post()
Daniel Stoch created WICKET-5619:
------------------------------------
Summary: ConcurrentModificationException may occur when calling EventBus.post()
Key: WICKET-5619
URL: https://issues.apache.org/jira/browse/WICKET-5619
Project: Wicket
Issue Type: Bug
Components: wicket-atmosphere
Affects Versions: 6.15.0
Reporter: Daniel Stoch
Assignee: Emond Papegaaij
ConcurrentModificationException may occur when calling EventBus.post() because subscriptionsForPage collection can be modified by another thread during a loop inside AtmosphereRequestHandler.executeHandlers:
{code}
java.util.ConcurrentModificationException
at java.util.HashMap$HashIterator.nextNode(HashMap.java:1429)
at java.util.HashMap$KeyIterator.next(HashMap.java:1453)
at com.google.common.collect.AbstractMultimap$WrappedCollection$WrappedIterator.next(AbstractMultimap.java:540)
at java.util.Collections$UnmodifiableCollection$1.next(Collections.java:1102)
at com.google.common.collect.Iterators$8.computeNext(Iterators.java:735)
at com.google.common.collect.AbstractIterator.tryToComputeNext(AbstractIterator.java:143)
at com.google.common.collect.AbstractIterator.hasNext(AbstractIterator.java:138)
at org.apache.wicket.atmosphere.AtmosphereRequestHandler.executeHandlers(AtmosphereRequestHandler.java:79)
at org.apache.wicket.atmosphere.AtmosphereRequestHandler.respond(AtmosphereRequestHandler.java:74)
at org.apache.wicket.request.cycle.RequestCycle$HandlerExecutor.respond(RequestCycle.java:862)
at org.apache.wicket.request.RequestHandlerStack.execute(RequestHandlerStack.java:64)
at org.apache.wicket.request.cycle.RequestCycle.execute(RequestCycle.java:261)
at org.apache.wicket.request.cycle.RequestCycle.processRequest(RequestCycle.java:218)
at org.apache.wicket.request.cycle.RequestCycle.processRequestAndDetach(RequestCycle.java:289)
at org.apache.wicket.atmosphere.EventBus.post(EventBus.java:417)
at org.apache.wicket.atmosphere.EventBus.postToSingleResource(EventBus.java:393)
at org.apache.wicket.atmosphere.EventBus.post(EventBus.java:346)
at org.apache.wicket.atmosphere.EventBus.post(EventBus.java:329)
{code}
I think the problem is inside in EventBus.postToSingleResource() method:
{code}
subscriptionsForPage = Collections2.filter( Collections.unmodifiableCollection(subscriptions.get(key)), new EventFilter(event));
{code}
I think collection get from "subscriptions.get(key)" should be copied first and then assigned to subscriptionsForPage variable. Now it is a pass as a reference (not directly but it is) and it can lead to ConcurrentModificationException.
It is not easy to reproduce this problem (more that one thread must call post at the same time), but sometimes it happen.
--
This message was sent by Atlassian JIRA
(v6.2#6252)