-
-
Notifications
You must be signed in to change notification settings - Fork 177
[BUG] ObjectMapper.readValue<T>(...) breaks null safety #399
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
[BUG] ObjectMapper.readValue<T>(...) breaks null safety #399
Comments
Interesting, adding that cast to the extensions functions makes sense to me, but I'm a bit wary as I'm not certain what side effects it might have. @viartemev do you have any insight? @revintec would you make a PR with casts on the extension functions? Depending on how confident we are, this could be part of 2.12.1 or might wait until 2.13. |
sorry for the late reply. as I discovered lately, it's more complicated than just add a
// should throw, instead we got a map with contaminated values
println(JSON.readValue<Map<String,Any>>("{\"key\":null}")) I think the right approach would be to add a |
Starting from |
Is there specific reason to use Also note that this probably should be changed for 3.0 when merging, as all |
@cowtowncoder
For exceptions used in |
@k163377 sorry, yes, I realized we just discussed this recently. All good. |
Jackson-module-kotlin version 2.9.7, newer version should experience the same problem
changing original source code
inline fun <reified T> ObjectMapper.readValue(content: String): T = readValue(content, jacksonTypeRef<T>())
adds trailing... as T
would fix the problem, however this way it provides poor exception messageException in thread "main" java.lang.NullPointerException: null cannot be cast to non-null type kotlin.Any
The text was updated successfully, but these errors were encountered: