Thread safety issue: incorrect usage of Collections.synchronizedMap in DefaultIoSessionDataStructureFactory.DefaultIoSessionAttributeMap ----------------------------------------------------------------------------------------------------------------------------------------
Key: DIRMINA-497 URL: https://issues.apache.org/jira/browse/DIRMINA-497 Project: MINA Issue Type: Bug Components: Core Reporter: David M. Lloyd In trunk, the DefaultIoSessionAttributeMap.setAttributeIfAbsent() synchronizes on the attributes map in order to synchronize access with the other get/setAttribute methods. However, Collections.synchronizedMap does NOT synchronize on the map itself, but rather an internal object! So, setAttributeIfAbsent() still contains a race condition. A good solution for 2.x would be to simply use a ConcurrentMap, which has putIfAbsent(). For 1.0.x, which has to run on JDK 1.4 (correct?), I'd recommend to just drop Collections.synchronizedMap() and synchronize directly on the Map reference itself. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.