-
Notifications
You must be signed in to change notification settings - Fork 22
-
Notifications
You must be signed in to change notification settings - Fork 22
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
Map computeIfAbsent is incorrect #142
Comments
Yes, but the computed value is allowed to be |
I argue if you are using Given that cache is used in performance areas it really is not desired to do another function call to either convert or check for null (e.g. I guess I could see a case for both uses but for folks that want it differently they could just make the map Caffeine has its cache computeIfAbsent like:
We don't have the luxury of I guess it makes since to keep it |
@J-N-K I know you sort of mentioned this in #116 but I'm now fairly positive
computeIfAbsent
for map is wrong.Should be
V is a free variable. It is not
@Nullable
like onget
.The Javadoc is:
For a
Map<@NonNull String, @NonNull String>
I think a reasonable assumption is the mappingFunction should return what type the map's key is and thanks to the generic V being@NonNull String
Eclipse will enforce it. I'm not sure why you had problems with this but if Map is correctly annotated I get correct warnings like:Ditto for
EDIT I got confused with some other method on ConcurrentHashMap likecomputeIfPresent
removeIf
.These annotations are on ConcurrentHashMap as well.
The text was updated successfully, but these errors were encountered: