-
Notifications
You must be signed in to change notification settings - Fork 174
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
[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 |
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: