Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix race condition in DefaultBroadcasterFactory in Atmosphere 0.8.x #100

Merged
merged 1 commit into from
Dec 6, 2011
Merged

Fix race condition in DefaultBroadcasterFactory in Atmosphere 0.8.x #100

merged 1 commit into from
Dec 6, 2011

Conversation

rogueserenity
Copy link

Race condition when performing a lookup and creating if null. The synchronized statement in get(Class<? extends Broadcaster> c, Object id) is insufficient to ensure that two threads don't create a broadcaster with the same ID. Two strings that are equal, but are different objects may enter the block at the same time. To fix, make the get() method call the lookup method, and change the lookup method to better use the ConcurrentHashMap methods to guarantee that only one broadcaster can be returned with a particular ID.

Fixed remove() to use ConcurrentHashMap method to guarantee atomicity.

Fix race condition in DefaultBroadcasterFactory
@@ -92,7 +92,7 @@
*
* @param b a {@link Broadcaster}
* @return false if wasn't present, or {@link Broadcaster}
* @oaram id the {@link Broadcaster's ID}
* @param id the {@link Broadcaster's ID}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed javadoc markup issue.

@jfarcand jfarcand merged commit 592ed26 into Atmosphere:atmosphere-0.8.x Dec 6, 2011
@jfarcand
Copy link
Member

jfarcand commented Dec 6, 2011

Many thanks. I've added the default license header, feel free to change it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants