Remove ServerWebExchange dependency in ServerRequestObservationContext
Avoiding cycle between http.server and web.server packages. See gh-30013
This commit is contained in:
@@ -51,6 +51,7 @@ class HttpWebHandlerAdapterObservabilityTests {
|
||||
|
||||
private final MockServerHttpResponse response = new MockServerHttpResponse();
|
||||
|
||||
|
||||
@Test
|
||||
void handlerShouldSetObservationContextOnExchange() {
|
||||
HttpStatusSuccessStubWebHandler targetHandler = new HttpStatusSuccessStubWebHandler(HttpStatus.OK);
|
||||
@@ -97,6 +98,7 @@ class HttpWebHandlerAdapterObservabilityTests {
|
||||
.hasObservationWithNameEqualTo("http.server.requests").that();
|
||||
}
|
||||
|
||||
|
||||
private static class HttpStatusSuccessStubWebHandler implements WebHandler {
|
||||
|
||||
private final HttpStatus responseStatus;
|
||||
@@ -109,12 +111,13 @@ class HttpWebHandlerAdapterObservabilityTests {
|
||||
|
||||
@Override
|
||||
public Mono<Void> handle(ServerWebExchange exchange) {
|
||||
this.observationContext = ServerRequestObservationContext.findCurrent(exchange);
|
||||
this.observationContext = ServerRequestObservationContext.findCurrent(exchange.getAttributes());
|
||||
exchange.getResponse().setStatusCode(this.responseStatus);
|
||||
return Mono.empty();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static class ReactorContextWebHandler implements WebHandler {
|
||||
|
||||
ContextView contextView;
|
||||
@@ -129,6 +132,7 @@ class HttpWebHandlerAdapterObservabilityTests {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static class ThrowingExceptionWebHandler implements WebHandler {
|
||||
|
||||
private final Throwable exception;
|
||||
@@ -141,11 +145,12 @@ class HttpWebHandlerAdapterObservabilityTests {
|
||||
|
||||
@Override
|
||||
public Mono<Void> handle(ServerWebExchange exchange) {
|
||||
this.observationContext = ServerRequestObservationContext.findCurrent(exchange);
|
||||
this.observationContext = ServerRequestObservationContext.findCurrent(exchange.getAttributes());
|
||||
return Mono.error(this.exception);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static class BadRequestExceptionHandler implements WebExceptionHandler {
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user