-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Inconsistent handling of Collections$UnmodifiableList VS Collections$UnmodifiableRandomAccessList #2265
Comments
Ok. What would help here is the reproduction of the problem, so I can consider what, if anything to do. |
What do you mean? There is a test case to reproduce the issue in the description, is there something else that you need?
I agree that, because it is not public API, it is not really clean for Jackson to add special cases like that. But pragmatically, it is quite useful to have this little help from Jackson for such common types. I believe it was not a mistake to include handling for these types in the first place, even if it is not recommended in general to rely on private APIs. |
@joffrey-bion I think I skimmed the description too fast, and missed the meat, 2-line test method. Sorry about that, and thank you for providing all the information. I hope to look into this soon; added it on:
where I track short-term work items. |
@joffrey-bion Thank you for reporting this issue -- I fixed this in |
@cowtowncoder Thanks a lot for looking into this and quickly fixing the issue! |
I'm sorry to bring that one up again, but I'm under the impression that the issue about unmodifiable collections (#1880) is still not solved completely.
In fact, the way the
CLASS_UNMODIFIABLE_LIST
is retrieved here yieldsCollections$UnmodifiableRandomAccessList
, and therefore only this type is currently supported by Jackson 2.9.8.However, using
Collections.unmodifiableList()
on aList
implementation that doesn't implementRandomAccess
will yield aCollections$UnmodifiableList
instead, which is not deserialized properly and fails with:This can be reproduced by adding the following test case in
TestDefaultForUtilCollections1868
:Or more generally for outside the project:
Currently
java.util.Collections.unmodifiableList()
can only return these 2 types of unmodifiable lists, so I believe it is safe for now to just hardcode yet another special case for this class.This can currently be solved on user side by adding a mixin, but since
Collections$UnmodifiableRandomAccessList
is supported, I would find it natural to also support the non-random access variant.The text was updated successfully, but these errors were encountered: