spring-framework icon indicating copy to clipboard operation
spring-framework copied to clipboard

Enhance UrlHandlerFilter with ordered pattern matching and status validation

Open jamesmissen opened this issue 6 days ago • 0 comments

This PR addresses issue #35882.

It does the following:

  1. Allows for ordering handlers based on path specificity, so handlers are selected based on how well a PathPattern matches the request path.

  2. Validates the HTTP status code for redirect handlers, using a simple assertion to check if the code is 3xx.

The changes are backwards compatible:

  1. A new useSpecificityOrder method is added to the Builder to opt in to specificity-based ordering. Not using this method (or using a value of false) results in the current behaviour.

  2. A new exclude method is added to the Builder to optionally exclude URL handling for specific patterns. Not using this method results in the current behaviour.

  3. For the servlet implementation, the parameter of the redirect method was changed from type HttpStatus to HttpStatusCode to align with the reactive implementation. This change will have no effect as HttpStatusCode is implemented by HttpStatus.

Feedback and edits are welcome, particularly regarding the implementation of specificity-based ordering, and the new method names (useSpecificityOrder and exclude).

jamesmissen avatar Dec 06 '25 06:12 jamesmissen