https://kotlinlang.org logo
#announcements
Title
# announcements
m

mplain

11/03/2020, 10:47 AM
Hi! Spring has a WebClient interface, written in Java That interface has the following method:
Copy code
contentType(MediaType contentType)
In my Kotlin code I call that method, passing a null Intellij IDEA Ultimate 2020.2 highlights it in red, saying: Null cannot be a value of a non-null type MediaType But there are no special annotations on the interface method Why does this happen, and how do I handle it? (I actually pass a nullable value, and the DefaultWebClient implementation calls a method annotated with @Nullable, so it can work with nulls)
t

thanksforallthefish

11/03/2020, 10:59 AM
more suited in #spring but either way spring has a way of marking entire packages to only accept non null parameters. I think it is
package-info
, it should be part of webflux library
m

mplain

11/03/2020, 11:03 AM
is this integration with Idea, or with the compiler?
anyway, cool! thanks 🙂
t

thanksforallthefish

11/03/2020, 11:11 AM
I think it is only ide, but I don’t know if it is also somehow integrated in build tools like gradle or other plugins. but it is not a compiler plugin (pretty sure of this)
a

Arian Stolwijk

11/03/2020, 12:41 PM
The kotlin compiler picks up JSR-305 annotations at least. Apparently https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/lang/NonNullApi.html applies it to all java methods
10 Views