Here are two different instances of ConcurrentModificationException we see in the logs. These started showing up after we turned on buddy lists. The first stack trace below is associated with an error message about unable to close client channel, and in our stack trace we are calling disconnectUser from our AS extension script. The second one doesn't have any extension in the stack trace.
====
INFO | jvm 1 | 2007/07/18 00:09:33 | 00:09:33.777 - [ WARNING ] > Unable to close client channel. Error: java.util.ConcurrentModificationException
INFO | jvm 1 | 2007/07/18 00:09:33 | java.util.ConcurrentModificationException
INFO | jvm 1 | 2007/07/18 00:09:33 | at java.util.HashMap$HashIterator.nextEntry(Unknown Source)
INFO | jvm 1 | 2007/07/18 00:09:33 | at java.util.HashMap$KeyIterator.next(Unknown Source)
INFO | jvm 1 | 2007/07/18 00:09:33 | at it.gotoandplay.smartfoxserver.data.BuddyListManager.getClientsToUpdate(BuddyListManager.java:251)
INFO | jvm 1 | 2007/07/18 00:09:33 | at it.gotoandplay.smartfoxserver.data.Zone.removeName(Zone.java:381)
INFO | jvm 1 | 2007/07/18 00:09:33 | at it.gotoandplay.smartfoxserver.SmartFoxServer.lostConnection(SmartFoxServer.java:1497)
INFO | jvm 1 | 2007/07/18 00:09:33 | at it.gotoandplay.smartfoxserver.controllers.SystemHandler.kickUser(SystemHandler.java:2438)
INFO | jvm 1 | 2007/07/18 00:09:33 | at it.gotoandplay.smartfoxserver.extensions.ExtensionHelper.disconnectUser(ExtensionHelper.java:857)
INFO | jvm 1 | 2007/07/18 00:09:33 | at sun.reflect.GeneratedMethodAccessor67.invoke(Unknown Source)
INFO | jvm 1 | 2007/07/18 00:09:33 | at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
INFO | jvm 1 | 2007/07/18 00:09:33 | at java.lang.reflect.Method.invoke(Unknown Source)
INFO | jvm 1 | 2007/07/18 00:09:33 | at org.mozilla.javascript.MemberBox.invoke(MemberBox.java:142)
INFO | jvm 1 | 2007/07/18 00:09:33 | at org.mozilla.javascript.NativeJavaMethod.call(NativeJavaMethod.java:201)
INFO | jvm 1 | 2007/07/18 00:09:33 | at org.mozilla.javascript.optimizer.OptRuntime.call1(OptRuntime.java:64)
INFO | jvm 1 | 2007/07/18 00:09:33 | at org.mozilla.javascript.gen.c27._c33(thu_challenge.as:687)
INFO | jvm 1 | 2007/07/18 00:09:33 | at org.mozilla.javascript.gen.c27.call(thu_challenge.as)
INFO | jvm 1 | 2007/07/18 00:09:33 | at org.mozilla.javascript.optimizer.OptRuntime.call1(OptRuntime.java:64)
INFO | jvm 1 | 2007/07/18 00:09:33 | at org.mozilla.javascript.gen.c27._c76(thu_challenge.as:1813)
INFO | jvm 1 | 2007/07/18 00:09:33 | at org.mozilla.javascript.gen.c27._c72(thu_challenge.as:1458)
INFO | jvm 1 | 2007/07/18 00:09:33 | at org.mozilla.javascript.gen.c27.call(thu_challenge.as)
INFO | jvm 1 | 2007/07/18 00:09:33 | at org.mozilla.javascript.optimizer.OptRuntime.callName(OptRuntime.java:95)
INFO | jvm 1 | 2007/07/18 00:09:34 | at org.mozilla.javascript.gen.c27._c46(thu_challenge.as:823)
INFO | jvm 1 | 2007/07/18 00:09:34 | at org.mozilla.javascript.gen.c27.call(thu_challenge.as)
INFO | jvm 1 | 2007/07/18 00:09:34 | at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:337)
INFO | jvm 1 | 2007/07/18 00:09:34 | at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:2755)
INFO | jvm 1 | 2007/07/18 00:09:34 | at org.mozilla.javascript.gen.c27.call(thu_challenge.as)
INFO | jvm 1 | 2007/07/18 00:09:34 | at it.gotoandplay.smartfoxserver.extensions.JavascriptExtension.callJavaScriptFunction(JavascriptExtension.java:443)
INFO | jvm 1 | 2007/07/18 00:09:34 | at it.gotoandplay.smartfoxserver.extensions.JavascriptExtension.handleRequest(JavascriptExtension.java:250)
INFO | jvm 1 | 2007/07/18 00:09:34 | at it.gotoandplay.smartfoxserver.controllers.ExtensionHandler.processEvent(ExtensionHandler.java:488)
INFO | jvm 1 | 2007/07/18 00:09:34 | at it.gotoandplay.smartfoxserver.controllers.ExtensionHandler.run(ExtensionHandler.java:378)
INFO | jvm 1 | 2007/07/18 00:09:34 | at java.lang.Thread.run(Unknown Source)
=== Stack trace #2 ===
INFO | jvm 1 | 2007/07/18 00:02:50 | 00:02:50.459 - [ WARNING ] > Unexpected Exception: java.util.ConcurrentModificationException
INFO | jvm 1 | 2007/07/18 00:02:50 | java.util.ConcurrentModificationException
INFO | jvm 1 | 2007/07/18 00:02:50 | at java.util.HashMap$HashIterator.nextEntry(Unknown Source)
INFO | jvm 1 | 2007/07/18 00:02:50 | at java.util.HashMap$KeyIterator.next(Unknown Source)
INFO | jvm 1 | 2007/07/18 00:02:50 | at it.gotoandplay.smartfoxserver.data.BuddyListManager.getClientsToUpdate(BuddyListManager.java:251)
INFO | jvm 1 | 2007/07/18 00:02:50 | at it.gotoandplay.smartfoxserver.controllers.SystemHandler.handleSetBuddyVars(SystemHandler.java:1833)
INFO | jvm 1 | 2007/07/18 00:02:50 | at it.gotoandplay.smartfoxserver.controllers.SystemHandler.processEvent(SystemHandler.java:280)
INFO | jvm 1 | 2007/07/18 00:02:50 | at it.gotoandplay.smartfoxserver.controllers.SystemHandler.run(SystemHandler.java:121)
INFO | jvm 1 | 2007/07/18 00:02:50 | at java.lang.Thread.run(Unknown Source)
ConcurrentModificationException
-
thinkaboutit
- Posts: 2
- Joined: 29 Dec 2007, 19:49
sorry for bringing up and old topic but I also get the ConcurrentModificationException error. I am currently working with cleint as3/sfs pro(1.6) Java extentions.
From the research that I've done so far I believe the problem is when using a HashMap to store data(could also be other data types not just HashMap issues). The reason for it is that most people such as myself will user an Iterator to loop though the HashMap when necessary. And the problem occurs when looping though the hashmap and the content of the hashmap gets changed(remove/put) which makes the iterator throw and error.
I would like to say that I do not have a solution to this problem and I'm not sure if this is correct but from research so far i think this happens when 2 threads conflict, such as one looping through the HashMap with an iterator and another thread editing the content of the HashMap.
My java experience is very limited so if anyone has a solution to this please let me know.
From the research that I've done so far I believe the problem is when using a HashMap to store data(could also be other data types not just HashMap issues). The reason for it is that most people such as myself will user an Iterator to loop though the HashMap when necessary. And the problem occurs when looping though the hashmap and the content of the hashmap gets changed(remove/put) which makes the iterator throw and error.
I would like to say that I do not have a solution to this problem and I'm not sure if this is correct but from research so far i think this happens when 2 threads conflict, such as one looping through the HashMap with an iterator and another thread editing the content of the HashMap.
My java experience is very limited so if anyone has a solution to this please let me know.
If you are using Java 5 (or higher) you can substitute the HashMap with a ConcurrentHashMap which takes care about synchronization behind the scenes.
http://java.sun.com/j2se/1.5.0/docs/api ... shMap.html
EDIT:
before Java 5 you could use something like this:
See this page: http://java.sun.com/j2se/1.5.0/docs/api ... tions.html
http://java.sun.com/j2se/1.5.0/docs/api ... shMap.html
EDIT:
before Java 5 you could use something like this:
Code: Select all
Map map = Collections.synchronize(new HashMap());