I created new Java Spring app and added one controller with one method:
@RestController
public class MyController {
@GetMapping("/test")
public String test() {
throw new ResponseStatusException(HttpStatus.NOT_FOUND);
}
}
When I’m trying to perform request GET /test
I get response with no body and 401 status code.
In STDOUT of my Spring app I can see output:
WARN 36 --- [nio-8080-exec-2] .w.s.m.a.ResponseStatusExceptionResolver : Resolved [org.springframework.web.server.ResponseStatusException: 404 NOT_FOUND]
Why I get 401 response instead of 404?