-
Couldn't load subscription status.
- Fork 38.8k
Closed as not planned
Closed as not planned
Copy link
Labels
in: webIssues in web modules (web, webmvc, webflux, websocket)Issues in web modules (web, webmvc, webflux, websocket)status: invalidAn issue that we don't feel is validAn issue that we don't feel is valid
Description
version: springboot 3.5.4
@ResponseStatus(HttpStatus.BAD_REQUEST) is 50 times less performant than @ResponseStatus(HttpStatus.UNAUTHORIZED)
Interface hello QPS 1000-2000, interface hello2 QPS 40000-60000
Below is a simple code reproduction:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>package com.example.demo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*;
@RestControllerAdvice
@RestController
@SpringBootApplication
public class Demo1Application {
public static void main(String[] args) {
SpringApplication.run(Demo1Application.class, args);
}
@GetMapping("/hello")
public String hello(){
throw new ParamsErrorException("error");
}
@GetMapping("/hello2")
public String hello2(){
throw new Params2ErrorException("error");
}
public static class ParamsErrorException extends RuntimeException{
public ParamsErrorException(String message){
super(message, null, true, false);
}
}
public static class Params2ErrorException extends RuntimeException{
public Params2ErrorException(String message){
super(message, null, true, false);
}
}
@ResponseStatus(HttpStatus.BAD_REQUEST)
@ExceptionHandler
public String exceptionHandler(ParamsErrorException e) {
return "error";
}
@ResponseStatus(HttpStatus.UNAUTHORIZED)
@ExceptionHandler
public String exceptionHandler(Params2ErrorException e) {
return "error2";
}
}

Metadata
Metadata
Assignees
Labels
in: webIssues in web modules (web, webmvc, webflux, websocket)Issues in web modules (web, webmvc, webflux, websocket)status: invalidAn issue that we don't feel is validAn issue that we don't feel is valid