Sergey Serdyuk
12/01/2021, 9:00 PM@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
@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.Ties
12/02/2021, 8:46 AMids
value is indeed not null 😛 you can use this on it though: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/filter-not-null.htmlAlexander Levin
12/02/2021, 10:51 AMMykola Gurov
12/02/2021, 5:20 PMSergey Serdyuk
12/03/2021, 2:23 PM