Affects: \Spring Boot v2.3.9.RELEASE, Spring v5.2.13.RELEASE
When annotating a parameter of type Long of a controller with @NotNull for a @Get method and passing the parameter as empty value, the parameter is received as null.
@RestController
@RequestMapping("testController1")
public class TestController {
@GetMapping("testMethod1")
public Long testMethod(@RequestParam @NotNull Long param1) {
assertNotNull(param1);
return param1;
}
}
Getting 400 when requesting http://localhost:8082/testController1/testMethod1 Getting 200 when requesting http://localhost:8082/testController1/testMethod1?param1=555 Getting 500 when requesting http://localhost:8082/testController1/testMethod1?param1=¶m2=bla
Expecting to 400 for the last case too.
Comment From: selalerercapitolis
Those two seem related: https://github.com/spring-projects/spring-framework/issues/15035 https://github.com/spring-projects/spring-framework/issues/15207
Comment From: sannnan
facing the same issue. Does it gets resolved?
my questions:
https://stackoverflow.com/questions/72712302/notnull-or-notempty-is-not-working-as-expected-spring-boot-controller
Comment From: bclozel
Closing as a duplicate of #16519 and #11041