Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@NotNull annotation is not enforced for @RequestParam when parameter is passed as an empty value #26841

Closed
selalerercapitolis opened this issue Apr 21, 2021 · 3 comments
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) status: duplicate A duplicate of another issue

Comments

@selalerercapitolis
Copy link

selalerercapitolis commented Apr 21, 2021

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=&param2=bla

Expecting to 400 for the last case too.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Apr 21, 2021
@selalerercapitolis
Copy link
Author

Those two seem related:
#15035
#15207

@rstoyanchev rstoyanchev added the in: web Issues in web modules (web, webmvc, webflux, websocket) label Nov 8, 2021
@sannnan
Copy link

sannnan commented Jun 22, 2022

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

@bclozel
Copy link
Member

bclozel commented Jun 22, 2022

Closing as a duplicate of #16519 and #11041

@bclozel bclozel closed this as not planned Won't fix, can't repro, duplicate, stale Jun 22, 2022
@bclozel bclozel added status: duplicate A duplicate of another issue and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Jun 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) status: duplicate A duplicate of another issue
Projects
None yet
Development

No branches or pull requests

5 participants