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 Java 8 dependency, now compiles under Java 7 #20

Closed
wants to merge 3 commits into from

Conversation

cobbzilla
Copy link

This library almost compiles under Java 7, but java.util.Map lacks a putIfAbsent method (added in Java 8). If we replace the regular Map with a ConcurrentHashMap (which does have this method), then it compiles fine.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 99.373% when pulling 67a0595 on qbisins:master into 709012c on piwik:master.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 99.373% when pulling b627336 on qbisins:master into 709012c on piwik:master.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 99.373% when pulling b627336 on qbisins:master into 709012c on piwik:master.


/**
*
* @author brettcsorba
*/
class CustomVariableList{
private final Map<Integer, CustomVariable> map = new HashMap<>();
private final ConcurrentHashMap<Integer, CustomVariable> map = new ConcurrentHashMap<>();
Copy link
Member

Choose a reason for hiding this comment

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

There's not a need to have calls to the map be thread safe, so we inherit unnecessary overhead using a concurrent hash map. If we want to remove the call to putIfAbsent, we can refactor that logic to use containsKey/put in the while loop.

@bcsorba
Copy link
Member

bcsorba commented Nov 13, 2016

Thanks for the pull request, but I've resolved this with the approach I've outlined above. Thanks for pointing this out!

@bcsorba bcsorba closed this Nov 13, 2016
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.

None yet

3 participants