Wednesday, December 11, 2013

Re: Getting ConcurrentModificationException

Thanks for your help. On server side I've used single thread executor to send all UI messages sequentially, then also I'm getting same exception.

Actually we are using GWT event service to send asynchronous messages from server to client. So now all RemoteEventServiceServlet.addEvent() are executed sequentially, then also it gives ConcurrentModificationException.


On server side GWT does not spawn any threads on its own. Everything is executed in the thread that handles the client request. Also GWT's Map serializer is stateless, see: https://gwt.googlesource.com/gwt/+/master/user/src/com/google/gwt/user/client/rpc/core/java/util/Map_CustomFieldSerializerBase.java

So if you sometimes have ConcurrentModificationExceptions then I am pretty sure (99%) that you have somewhere a HashMap instance lying around that gets modified while being serialized. I could imagine that you have a HashMap somewhere stored in a field and want that HashMap to be pushed to all clients once it gets modified. In that case you need to create a copy of that map before pushing it to the client.

It's irrelevant if you push things one by one (single thread executor). If the map in question gets modified while a single push is in progress you will get the exception.

Check your Map usages on the server.

-- J.

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment