Affects: 5.2.5

Description In 5.2.5 version MockServerRequest has been deprecated in favor of ServerRequest.create(ServerWebExchange, List)} combined with MockServerWebExchange.

Implementation of pathVariables() method in DefaultServerRequest looks like:

@Override
public Map<String, String> pathVariables() {
    return this.exchange.getAttributeOrDefault(
        RouterFunctions.URI_TEMPLATE_VARIABLES_ATTRIBUTE, Collections.emptyMap());
}

And the problem is that URI_TEMPLATE_VARIABLES_ATTRIBUTE attribute is not set during creation of MockServerWebExchange.

So, it's impossible to get pathVariables from DefaultServerRequest implementation of ServerRequest when it's created from MockServerRequest and MockServerWebExchange.

Example of how I'm using MockServerRequest in tests (Spock).

final mockServerHttpRequest = MockServerHttpRequest
                .post('/foo/{bar}/{bar1}', 'var1', 'var2')
                .contentType(MediaType.APPLICATION_JSON)
                .body('{}')
final mockServerWebExchange = MockServerWebExchange.from(mockServerHttpRequest)
final mockServerRequest = ServerRequest.create(mockServerWebExchange, HandlerStrategies.withDefaults().messageReaders())

And then this mockServerRequest is passed into handler function as an argument.

Comment From: poutsma

I do not see an easy way to resolve this, so I am undoing the deprecation.