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

Report a misuse of ConcurrentHashMap #87

Open
baigd opened this issue Sep 14, 2015 · 0 comments
Open

Report a misuse of ConcurrentHashMap #87

baigd opened this issue Sep 14, 2015 · 0 comments

Comments

@baigd
Copy link

baigd commented Sep 14, 2015

Hi, Developers of alibaba/mdrill,

I am writing to report a misuse of ConcurrentHashMap, which may lead to efficiency problem. I would very appreciate if you could check below for details and confirm with us whether it is a real problem.

File: "alibaba/mdrill/trunk/adhoc-solr/src/main/java/org/apache/solr/client/solrj/beans/DocumentObjectBinder.java"
Location: Line 100
Description:
The synchronized block form line 100 to line 102 only contains one update operation to the ConcurrentHashMap object. According to the Java API specifications, ConcurrentHashMap can guarantee "high expected concurrency for updates". In this case, there is no multiple operations (such as check-then-act operation) which need atomicity guarantees. Therefore the concurrency can be guaranteed by ConcurrentHaspMap. The locking in line 100 may not be necessary since it causes efficiency problems, which is against the motivation to use the Concurrent Collections. Relying on the ConcurrentHashMap to ensure exclusive access is dangerous since ConcurrentHashMap has no guarantee of exclusive access.

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

No branches or pull requests

1 participant