-
-
Notifications
You must be signed in to change notification settings - Fork 336
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
Java 9 Immutable List Nullpointer #1263
Comments
List.of() API docs say that NPE will be thrown for any null elements: https://docs.oracle.com/javase/9/docs/api/java/util/List.html#of-E- |
@qualidafial yes thats right, but in case of contains, the List will throw a NPE if asked if it contains null |
Do you want Jdbi to stop calling contains() because one implementation doesn't guard against null? |
This very much sounds like a non-jdbi-issue to me, for what my opinion's worth. It's not jdbi's fault the list decides to throw an npe on null items it contains (why can you even get a null into it if it doesn't like nulls?). Jdbi needs to check for nulls, so it does. Your issue is with the list implementation you decided to use. |
@TheRealMarnes @qualidafial I agree it isn't an jdbi issue, but isn't it desireable to at least support all types of list the JCL provides, a fix would be to do it simmilar to the |
This List.of that throws an npe on contains when it has null items (that you still got into the list in the first place) and doesn't throw that npe when you stream the items (because logic) is seriously a jdk implementation? I mean, jdbi kinda has to support it then, but I can't wrap my head around such a thing actually being in the jdk. |
@TheRealMarnes Yes it is, that is why I opened this Issue. |
I'm in favor of a workaround in jdbi then, but it'll be with an angry look toward the jdk and a code comment explaining that the relevant code in jdbi has no right to exist then ¯\_(ツ)_/¯ |
I will open a pull request then |
Thanks for tracking this down, everyone :) |
@TheRealMarnes You got something wrong there: The The Javadoc is clear on the behavior of
So in my opinion this is a concern on the side of Jdbi and not an issue in the JDK itself - the JDK team made this decision (for some reason) and everyone has to stick to it. |
Yeah, I just noticed that the optional Still think it breaks LSP but it's in the spec so we'll deal with it |
values.contains(null)
throws a nullpointer exception if list is created withList.of()
, since it'scontains
method produces a NullpointerException if filled with null:The text was updated successfully, but these errors were encountered: