Skip to content

WebTestClient.bindToRouterFunction(...) with exception handler not working [SPR-17239] #21772

@spring-projects-issues

Description

@spring-projects-issues

rodolphocouto opened SPR-17239 and commented

This bug occurs when the WebTestClient is used to test a router function with custom exception handler, for example:

 

WebTestClient
    .bindToRouterFunction(myRouter())
    .handlerStrategies(HandlerStrategies.builder()
        .exceptionHandler(new CustomExceptionHandler()) // IS NOT CALLED :(
        .build())
    .build()

 

 

With annotated controllers, the same custom exception is called, for example:

 

WebTestClient
    .bindToController(new MyController())
    .controllerAdvice(new CustomExceptionHandler()) // IS CALLED :)
    .build()

 


Affects: 5.0.8

Reference URL: https://github.com/rodolphocouto/spring-framework-issues/tree/master/SPR-17239

Metadata

Metadata

Assignees

Labels

in: testIssues in the test modulein: webIssues in web modules (web, webmvc, webflux, websocket)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions