I have this Kotlin code using Spring Boot 3/Spring Framework 6.2:
fun someRestCall(name: String?): Details {
return restClient.get().uri("/{name}/details", name).retrieve().body(Details::class.java)!!
}
Where uri
takes a String and a vararg of Object
.
Upgrading to Spring Framework 7, I am getting:
MyService.kt:35:49 Argument type mismatch: actual type is 'kotlin.String?', but 'kotlin.Any' was expected.
I upgraded to Kotlin 2.1 in a separate commit so it looks like the extra checks might come from Spring Framework 7.0 itself. The new behavior looks more correct to me but I am wondering why it isn't failing in 6.x.
Comment From: sdeleuze
This is a side effect of #28797 due to the fact that the related Object... uriVariables
parameter element nullness was not managed with JSR 305 while it is now. The implementation indicates that URI variables are nullable and that makes sense to be lenient here, so I will refine the nullness of that API accordingly.
Comment From: snicoll
I've moved this to a task as we haven't released the new behavior with the regression yet so it isn't technically one.