[ 
https://issues.apache.org/jira/browse/DIRMINA-497?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12552321
 ] 

Trustin Lee commented on DIRMINA-497:
-------------------------------------

Are you sure that the Map implementation that Collections.synchronizedMap() 
returns uses the internal object for synchronization?  I looked into the 
JavaDoc and JDK source code, but it seems like it synchronizes with the 
returned Map instance itself.  Could you check that again?

BTW, we have reverted back from ConcurrentHashMap to synchronized HashMap due 
to excessive memory usage of ConcurrentHashMap.  It would be really nice if 
there's a compact ConcurrentHashMap implementation that doesn't consume too 
much heap.

> 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
>         Attachments: DIRMINA-497-1.patch
>
>
> 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.

Reply via email to