[jboss-user] [JBoss Cache: Core Edition] - Getting data from a node

FredrikJ do-not-reply at jboss.com
Wed Apr 30 04:52:38 EDT 2008


We have seen ConcurrentModificationExceptions in our system when handling data maps returned from a node. In the JBC javadoc it is specified that the method Node.getData() should return an immutable map.

anonymous wrote :     Returns:
  |         a Map containing the data in this Node. If there is no data, an empty Map is returned. The Map returned is always immutable.
  | 

Is this still true for 2.1.0.GA? Since there was no other way I could possibly see the exception occur in our system I whipped together a quick test to see if I could rely on the returned map not to change. What I found was that you cannot safely iterate the returned data map if other threads are changing the cache, which seems to imply that the returned map is not immutable.

You can find the simple test here: http://www.cubeia.com/misc/nodedata/

It is not possible to take a defensive copy of the map either since we then might end up with a ConcurrentModificationExceptions in the initialization of the new map (this was actually the case of the original error).

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4147749#4147749

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4147749



More information about the jboss-user mailing list