Skip to content
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

Null validation produces a false negative on nullable collections that contain null #1

Open
robpridham-bbc opened this issue Oct 23, 2019 · 0 comments

Comments

@robpridham-bbc
Copy link

If you run the null validation in containsIllegalNullValues on a nullable list, e.g.:

val nullableListWithNull = listOf<String?>(null)

then it will return false, because on iterating through the list, element is null. This may seem like an odd scenario but we experience it when using Gson with a custom deserialiser that ignores certain elements, for which it returns null.

I did look at whether it was possible to improve on this, e.g. examine the return type of the collection's iterator to see if isMarkedNullable would be true, but I couldn't find a working solution. I think this a product of how Kotlin does generics, e.g. https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.reflect/-k-type/is-marked-nullable.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant