Skip to content

Commit 79408d7

Browse files
committed
Fix observation race condition in WebFlux test
There is a race condition when we already have a reply, but the span in the last channel is not closed yet.
1 parent 7655d97 commit 79408d7

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

spring-integration-webflux/src/test/java/org/springframework/integration/webflux/observation/WebFluxObservationPropagationTests.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
import org.springframework.web.server.adapter.WebHttpHandlerBuilder;
6464

6565
import static org.assertj.core.api.Assertions.assertThat;
66+
import static org.awaitility.Awaitility.await;
6667

6768
/**
6869
* @author Artem Bilan
@@ -123,7 +124,8 @@ void observationIsPropagatedWebFluxRequestReply() {
123124
.expectBody(String.class)
124125
.isEqualTo(testData.toLowerCase());
125126

126-
assertThat(SPANS.spans()).hasSize(3);
127+
// There is a race condition when we already have a reply, but the span in the last channel is not closed yet.
128+
await().untilAsserted(() -> assertThat(SPANS.spans()).hasSize(3));
127129
SpansAssert.assertThat(SPANS.spans().stream().map(BraveFinishedSpan::fromBrave).collect(Collectors.toList()))
128130
.haveSameTraceId();
129131
}

0 commit comments

Comments
 (0)