Remove ServerWebExchange dependency in ServerRequestObservationContext

Avoiding cycle between http.server and web.server packages.

See gh-30013
This commit is contained in:
Juergen Hoeller
2023-06-14 21:57:27 +02:00
parent 220995b830
commit f00a8cb3a3
7 changed files with 40 additions and 22 deletions

View File

@@ -174,7 +174,7 @@ public class RouterFunctionMapping extends AbstractHandlerMapping implements Ini
org.springframework.web.filter.reactive.ServerHttpObservationFilter
.findObservationContext(serverRequest.exchange())
.ifPresent(context -> context.setPathPattern(matchingPattern.toString()));
ServerRequestObservationContext.findCurrent(serverRequest.exchange())
ServerRequestObservationContext.findCurrent(serverRequest.exchange().getAttributes())
.ifPresent(context -> context.setPathPattern(matchingPattern.toString()));
}
Map<String, String> uriVariables =

View File

@@ -170,7 +170,7 @@ public abstract class AbstractUrlHandlerMapping extends AbstractHandlerMapping {
org.springframework.web.filter.reactive.ServerHttpObservationFilter
.findObservationContext(exchange)
.ifPresent(context -> context.setPathPattern(pattern.toString()));
ServerRequestObservationContext.findCurrent(exchange)
ServerRequestObservationContext.findCurrent(exchange.getAttributes())
.ifPresent(context -> context.setPathPattern(pattern.toString()));
exchange.getAttributes().put(PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE, pathWithinMapping);
exchange.getAttributes().put(URI_TEMPLATE_VARIABLES_ATTRIBUTE, matchInfo.getUriVariables());

View File

@@ -145,7 +145,7 @@ public abstract class RequestMappingInfoHandlerMapping extends AbstractHandlerMe
org.springframework.web.filter.reactive.ServerHttpObservationFilter
.findObservationContext(exchange)
.ifPresent(context -> context.setPathPattern(bestPattern.toString()));
ServerRequestObservationContext.findCurrent(exchange)
ServerRequestObservationContext.findCurrent(exchange.getAttributes())
.ifPresent(context -> context.setPathPattern(bestPattern.toString()));
exchange.getAttributes().put(URI_TEMPLATE_VARIABLES_ATTRIBUTE, uriVariables);
exchange.getAttributes().put(MATRIX_VARIABLES_ATTRIBUTE, matrixVariables);