Skip to content

Refine ModelAttributeMethodProcessor Kotlin exception handling #23846

Closed
@trygveaa

Description

@trygveaa

I have a kotlin class with a non-nullable property, which is not using a primitive type in the jvm, and I'm trying to use the properties of that class as request parameters. If I don't include that property as a request parameter, I would expect a bad request response. However, it instead crashes with this exception:

java.lang.IllegalArgumentException: Parameter specified as non-null is null: method no.finntech.iaap.data_import.Params.<init>, parameter a

This is the code I'm using:

class Params(
        val a: String
)

@SpringBootApplication
@RestController
class Application {
    @GetMapping("/test")
    fun test(params: Params) = ""
}

If a is of type Int instead, or if I use a non-nullable String directly in the arguments to test as a RequestParam, I get a bad request as expected.

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)theme: kotlinAn issue related to Kotlin supporttype: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions