Skip to content

Commit 045f870

Browse files
mp911deschauder
authored andcommitted
Polishing.
Clean up residual observations after tests. See #5082 Original pull request #5083
1 parent f7c9b7b commit 045f870

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

spring-data-mongodb/src/test/java/org/springframework/data/mongodb/observability/MongoObservationCommandListenerTests.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import org.assertj.core.api.Assertions;
3232
import org.bson.BsonDocument;
3333
import org.bson.BsonString;
34+
import org.junit.jupiter.api.AfterEach;
3435
import org.junit.jupiter.api.BeforeEach;
3536
import org.junit.jupiter.api.Test;
3637

@@ -72,6 +73,15 @@ void setup() {
7273
this.listener = new MongoObservationCommandListener(observationRegistry);
7374
}
7475

76+
@AfterEach
77+
void tearDown() {
78+
Observation currentObservation = observationRegistry.getCurrentObservation();
79+
if (currentObservation != null) {
80+
currentObservation.stop();
81+
observationRegistry.setCurrentObservationScope(null);
82+
}
83+
}
84+
7585
@Test
7686
void commandStartedShouldNotInstrumentWhenAdminDatabase() {
7787

0 commit comments

Comments
 (0)