Skip to content

Commit

Permalink
Fix race condition in the ObservationTests
Browse files Browse the repository at this point in the history
The listener may also report its span before we assert against current `tracer.getSpans()`
  • Loading branch information
artembilan committed Nov 13, 2024
1 parent 0318c1d commit be53360
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,9 @@ public void configure(Map<String, ?> configs) {
}
});

MessageListenerContainer listenerContainer1 = rler.getListenerContainer("obs1");
listenerContainer1.stop();

template.send(OBSERVATION_TEST_1, "test")
.thenAccept((sendResult) -> spanFromCallback.set(tracer.currentSpan()))
.get(10, TimeUnit.SECONDS);
Expand All @@ -166,7 +169,7 @@ public void configure(Map<String, ?> configs) {
"key", "value"));

assertThat(spanFromCallback.get()).isNotNull();
MessageListenerContainer listenerContainer1 = rler.getListenerContainer("obs1");
listenerContainer1.start();
MessageListenerContainer listenerContainer2 = rler.getListenerContainer("obs2");
assertThat(listenerContainer1).isNotNull();
assertThat(listenerContainer2).isNotNull();
Expand Down

0 comments on commit be53360

Please sign in to comment.