Skip to content

@ControllerAdvice ordering issue: Specific configuration is not prioritized over global configuration #35463

@kgonia

Description

@kgonia

I have multiple @ControllerAdvice classes configured in my project.

One has a configuration limited to a specific package:

@ControllerAdvice("xyz.configuration")
public class ExceptionMapper

A second one has a more broad configuration:

@ControllerAdvice
public class GlobalExceptionHandler

With this setup, the ExceptionHandlerExceptionResolver picks the GlobalExceptionHandler over the ExceptionMapper.

My expectation was for the more narrowly configured class to be picked before the broader one.

Do you share this view, or do you think using @order is the correct approach here?

Metadata

Metadata

Assignees

No one assigned

    Labels

    in: webIssues in web modules (web, webmvc, webflux, websocket)status: feedback-providedFeedback has been providedstatus: waiting-for-triageAn issue we've not yet triaged or decided on

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions