Skip to content

Consider not handling NoResourceFoundException in WebFlux #34236

@bclozel

Description

@bclozel

While working on ProblemDetail support for error views in Spring Boot (See spring-projects/spring-boot#19525), I have noticed that the org.springframework.web.reactive.result.method.annotation.ResponseEntityExceptionHandler handles all NoResourceFoundException instances as Problem Detail JSON/XML responses.

This exception is thrown for all 404s in the application, meaning that a browser requesting a missing page will always get a JSON response.

In the current error handling support for Spring Boot, the application can contribute an ErrorWebExceptionHandler which can render errors as JSON payloads or HTML views. Because it is ordered after the ResponseEntityExceptionHandler, there is no chance for Spring Boot to render HTML error pages for 404s.

I don't think there is a way to really understand the intent of the client here in Spring Framework. Spring Boot does that by checking that the client requests "text/html" explicitly.

This is an important change to consider in 6.2.x, but I'm wondering how we can unlock this use case for Spring Boot. Isn't handling

Metadata

Metadata

Assignees

No one assigned

    Labels

    in: webIssues in web modules (web, webmvc, webflux, websocket)status: supersededAn issue that has been superseded by another

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions