I validate the List size using java validation @Size:
@RestController
@RequestMapping(value = "/", produces = {"application/json;charset=UTF-8"})
@Validated
public class TestController {
@RequestMapping(
value = "/test",
method = RequestMethod.POST)
public void addResource(
@Valid
**@Size(min=1,max=3)**
@Valid @RequestBody List<TestDTO> testList) {
.....
}
}
when I send a request and list size is huge (about 700000), then the cpu usage is 100%. how I resolve it ? Is it a @Size bug?
the request body (700000 []):
[{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},.......
.......
.......
.......
]
I use springBoot3, jakarta.validation-api:3.0.2
I try to limit size of request body, Is there any other solution?
It is my code bug in my custom message trace filter.