Affects: \


When defining a RouterFunction like:

fun route() =  RouterFunctions.route(
        GET("/test").and(accept(MediaTpye("application", "example", mapOf("param" to "value1"))), this::handler1)

    ).and(RouterFunctions.route(
        GET("/test").and(accept(MediaTpye("application", "example", mapOf("param" to "value2"))), this::handler2)
    )

handler2 is never called, no matter wich Media Type I send with a request.

The issues seams to come direct from the MediaType class, which has a isCompatibleWith(mediaTpye: MediaTpye) method. This method just callssuper.isCompatibleWith(mediaTpye)` from MimeTpye.

This method is used in the class RequestPredicates() in line 784ff where the AcceptPredicate is evaluated.

Seams that in spring-mvc this is working. Just for Router Functions the parameters of the MediaTpye are just ignored.

Comment From: snicoll

Thanks for the report but please move that code in text into a sample we can actually run. You can attach a zip here or push the code to a GitHub repository.

Comment From: bclozel

I think this is a duplicate of https://github.com/spring-projects/spring-framework/issues/17949 - we only check that the media type is compatible and we can't use parameters there. See #17949 and the linked issues for some history on that.

Furthermore, supporting this feature in the functional web framework would be impossible: routes and their predicates are processed one by one and the first match wins. We cannot match or decline based on the media type parameter without knowing if another route down the line would also match.

Comment From: GeorgHoffmeyer

@bclozel I have a small example here: https://github.com/GeorgHoffmeyer/spring-boot-mime-type

This also shows that spring-boot-web and spring-boot-webflux behave different. While I can define Endpoints with MimeTpye Parameters in spring-boot-web this is not workling with router functions.

Comment From: snicoll

I am wondering if you took what Brian said above in consideration, that is:

Furthermore, supporting this feature in the functional web framework would be impossible: routes and their predicates are processed one by one and the first match wins. We cannot match or decline based on the media type parameter without knowing if another route down the line would also match.

Comment From: GeorgHoffmeyer

The fact here is, that the parameter from the MediaTpye is ignored complete in functional web framework. I understand if I have more then one endpoint with the same accept or ContentType definitions that the first match wins. But in my test this is not given.

Comment From: GeorgHoffmeyer

As mentioned in #17949 the MediaType.isCompatibleWith() Method, just ignores the MediaType Parameters, which is the cause of this behavior.

Comment From: GeorgHoffmeyer

Hi I just provieded some impl to show how the expected behavior would be.