Hi, I got next case with spring boot rest api: ```...
# server
s
Hi, I got next case with spring boot rest api:
Copy code
@RestController
@RequestMapping("/my_controller")
class MyController {

    @GetMapping(produces = [MediaType.APPLICATION_JSON_VALUE])
    fun getIds(@RequestParam(value = "ids") ids: List<Long>): List<Long> = ids
}
when I call for example:
curl -ik localhost:8080/my_controller?ids=1,2,3
all good but when my client send an empty value for example:
curl -ik localhost:8080/my_controller?ids=1,,3
the list
ids
don't check nullability and my method got
[1,null,3]
I suppose the problem around conversion from java to kotlin cause when I decompile class to java I see next
Copy code
@NotNull
public List getIds(@RequestParam("ids") @NotNull List ids) {
   Intrinsics.checkNotNullParameter(ids, "ids");
there is no any nullability checking, any ideas how to fix it, and where is the root of problem? thanks.
t
tbf, your
ids
value is indeed not null 😛 you can use this on it though: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/filter-not-null.html
💯 1
m
You could also change the parameter to String and do parsing/validation yourself - if this floats your boat.
s
@Alexander Levin looks like, thanks.