Skip to content

ExceptionHandler in the controller is not displayed when the controller is AOP Proxy class. #2098

Closed
@uc4w6c

Description

@uc4w6c

Describe the bug
If i add the Validated annotation etc. to the controller, it will become an AOP Proxy class, but the response returned by ExceptionHandler will not be displayed.

To Reproduce
GET /exception

@RestController
@RequestMapping("exception")
@Validated
public class ExceptionController {
  @GetMapping
  public String index() {
    throw new ExampleException();
  }

  @ExceptionHandler(ExampleException.class)
  @ResponseStatus(HttpStatus.BAD_REQUEST)
  @ApiResponse(responseCode = "400", description = "bad request")
  public String customControllerException() {
    return "exception1";
  }
}

Expected behavior

Actual

		"/exception": {
			"get": {
                                 ...
				"responses": {
					"200": {
                                          ...
					},
					"400": {
                                          ...
					}
				}
			}
		}

Expected:

		"/exception": {
			"get": {
                                 ...
				"responses": {
					"200": {
                                          ...
					}
				}
			}
		}

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions