Browse Source

Merge branch '6.1.x'

pull/32405/head
Brian Clozel 2 years ago
parent
commit
c1bd9243ee
  1. 2
      spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultWebClient.java
  2. 5
      spring-webflux/src/test/java/org/springframework/web/reactive/function/client/WebClientObservationTests.java

2
spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultWebClient.java

@ -471,7 +471,7 @@ final class DefaultWebClient implements WebClient {
final AtomicBoolean responseReceived = new AtomicBoolean(); final AtomicBoolean responseReceived = new AtomicBoolean();
return responseMono return responseMono
.doOnNext(response -> responseReceived.set(true)) .doOnNext(response -> responseReceived.set(true))
.doOnError(observationContext::setError) .doOnError(observation::error)
.doFinally(signalType -> { .doFinally(signalType -> {
if (signalType == SignalType.CANCEL && !responseReceived.get()) { if (signalType == SignalType.CANCEL && !responseReceived.get()) {
observationContext.setAborted(true); observationContext.setAborted(true);

5
spring-webflux/src/test/java/org/springframework/web/reactive/function/client/WebClientObservationTests.java

@ -110,7 +110,8 @@ class WebClientObservationTests {
StepVerifier.create(client.get().uri("/path").retrieve().bodyToMono(Void.class)) StepVerifier.create(client.get().uri("/path").retrieve().bodyToMono(Void.class))
.expectError(IllegalStateException.class) .expectError(IllegalStateException.class)
.verify(Duration.ofSeconds(5)); .verify(Duration.ofSeconds(5));
assertThatHttpObservation().hasLowCardinalityKeyValue("exception", "IllegalStateException") assertThatHttpObservation().hasError()
.hasLowCardinalityKeyValue("exception", "IllegalStateException")
.hasLowCardinalityKeyValue("status", "CLIENT_ERROR"); .hasLowCardinalityKeyValue("status", "CLIENT_ERROR");
} }
@ -172,7 +173,7 @@ class WebClientObservationTests {
StepVerifier.create(responseMono) StepVerifier.create(responseMono)
.expectError(IllegalStateException.class) .expectError(IllegalStateException.class)
.verify(Duration.ofSeconds(5)); .verify(Duration.ofSeconds(5));
assertThatHttpObservation() assertThatHttpObservation().hasError()
.hasLowCardinalityKeyValue("exception", "IllegalStateException") .hasLowCardinalityKeyValue("exception", "IllegalStateException")
.hasLowCardinalityKeyValue("status", "200"); .hasLowCardinalityKeyValue("status", "200");
} }

Loading…
Cancel
Save