Skip to content
This repository has been archived by the owner on Jan 9, 2018. It is now read-only.

TimeoutHashMap is not threadsafe #22

Open
trumpetinc opened this issue Feb 13, 2014 · 0 comments
Open

TimeoutHashMap is not threadsafe #22

trumpetinc opened this issue Feb 13, 2014 · 0 comments
Assignees
Labels
Milestone

Comments

@trumpetinc
Copy link
Collaborator

Right now, I'm pretty sure that the TimeoutHashMap implementation is not threadsafe. This places a large burden on DefaultRPCSender to manage synchronization. Otherwise, two calls to put(...) could corrupt the underlying data structure. With the current timeout thread running, there is a race condition that could get really ugly under load.

I have committed load test demonstrates one of the issues within a few seconds (I believe that there are other concurrency issues as well, but this hits an easy one) - see https://github.com/ghetolay/jwamp/blob/master/jwamp-core/src/test/java/com/github/ghetolay/jwamp/utils/TimeoutHashMapLoadTest.java

The fix for this particular race is to have TimeoutHashMap extend from ConcurrentHashMap - but I would prefer to consider a different design for TimeoutHashMap (I will open another issue on that).

@trumpetinc trumpetinc added the bug label Feb 13, 2014
@ghetolay ghetolay self-assigned this Feb 14, 2014
@ghetolay ghetolay added this to the JSR356 milestone Feb 19, 2014
ghetolay added a commit that referenced this issue Mar 3, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants