-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
MapSerializer._orderEntries()
throws NPE when operating on ConcurrentHashMap
#1513
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
Comments
Ok, thank you for reporting this. From exception it sounds like one should verify that keys implement |
@cowtowncoder hmm. Not sure if I follow. The key being queried on the ConcurrentSkipListMap does not necessarily exist in the map, it looks to be a test query made by Jackson.
The issue is triggered when
All the keys in the map being serialized implement |
we have the same issue. we had to rollback to jackson databind |
I can not reproduce the problem with simple @Sovietaced @mathieucarbou Has this been reproduced with version
would seem to cover for this specific case. |
Oh sorry! No our issue is still a NPE but when dealing with TreeMap, in version 2.8.6. Actually, in 2.8.6, there is this code (see #1411):
The comment is wrong: if
Yes, checking for
Because if I understand correctly, what you wanted (I think) is to return the map if it "could" contain null keys, and consequently you are not able to order the keys. |
@mathieucarbou I can not reproduce the issue; I am looking for for actual way to replicate the problem you have. Without this explanations of problem will not help. As to check: no. If we get |
OK, fine :-)
I'll be able to provide a junit test to reproduce on Monday.
…-- Mathieu
On Feb 18, 2017 19:01, "Tatu Saloranta" <notifications@github.com> wrote:
@mathieucarbou <https://github.com/mathieucarbou> I can not reproduce the
issue; I am looking for for actual way to replicate the problem you have.
Without this explanations of problem will not help.
As to check: no. If we get SortedMap, it is already good as is and further
processing would be waste of time (as well as hit null related issues).
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1513 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AADvomr-ZWPvCW2ps2YntuTm7g2dryFOks5rd4ZMgaJpZM4L0Wjq>
.
|
@cowtowncoder the problem that we experienced (that @Sovietaced reported) arose because we wrapped the The map wrapper returned by I think the code in #1411 needs to be rethought. The contract of java.util.Map says that:
I.e., it is not a safe operation to call IMHO the right way to fix the problem in #1411 is, instead of using a TreeMap directly, to implement a SortedMap (e.g., |
At this point I slightly disagree with the root causes analysis: in my opinion, the fundamental root cause is that SOME MAPS do not allow storage of Some map implementations have restrictions on the keys and values they may contain. For example, some implementations prohibit null keys and values, and some have restrictions on the types of their keys. Attempting to insert an ineligible key or value throws an unchecked exception, typically NullPointerException or ClassCastException. Attempting to query the presence of an ineligible key or value may throw an exception, or it may simply return false; some implementations will exhibit the former behavior and some will exhibit the latter. It is also worth noting that the check for I am also bit uneasy about building yet more complex work-arounds for likely open-ended sets of Map types: especially as it is not at all guaranteed that one can construct marker objects that do not fail (considering key value checks may or may not use full type, so could fail with But I am open to PRs for fixes for specific set of types. Since the method in question is part of internal |
I can reproduce the issue with |
MapSerializer._orderEntries()
throws NPE when operating on ConcurrentHashMap
For sake of completeness: further work-around here is to only check for existence of |
Thanks @cowtowncoder for the fix! I took a look at 64967c4 and I agree that it is better to only whitelist And yes, |
Thank you @cowtowncoder |
@andi-bigswitch correct; it's a fringe case since there's no real good way for @Sovietaced thank you for reporting this -- it's part of |
It seems that the fix introduced for #1411 in 2.8 can be problematic for ConcurrentSkipListMap (and possibly other map data structures).
doc for ConcurrentSkipListMap.doGet()
The text was updated successfully, but these errors were encountered: