[
https://issues.apache.org/jira/browse/WICKET-5619?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14098308#comment-14098308
]
ASF subversion and git services commented on WICKET-5619:
---------------------------------------------------------
Commit 78fc5b53eb09a76a2e7f307f2ce5fbbd2c8f6c0a in wicket's branch
refs/heads/wicket-6.x from [~mgrigorov]
[ https://git-wip-us.apache.org/repos/asf?p=wicket.git;h=78fc5b5 ]
WICKET-5619 ConcurrentModificationException may occur when calling
EventBus.post()
Use Iterables#filter() as suggested at
com.google.common.collect.Collections2#filter
> 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: Martin Grigorov
> Labels: atmosphere
> Fix For: 7.0.0-M3, 6.17.0
>
>
> 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)