Skip to content

Commit f22198e

Browse files
committed
moved logic of ExponentialBackoff cleanup to correct class
1 parent 4756404 commit f22198e

3 files changed

Lines changed: 18 additions & 4 deletions

File tree

driver-core/src/test/unit/com/mongodb/internal/time/ExponentialBackoffTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ void testCustomJitter() {
7070
// Test with jitter = 0, all backoffs should be 0
7171
ExponentialBackoff.setTestJitterSupplier(() -> 0.0);
7272
try {
73-
for (int attemptNumber = 1; attemptNumber < expectedBackoffs.length; attemptNumber++) {
73+
for (int attemptNumber = 1; attemptNumber < EXPECTED_BACKOFFS_MAX_VALUES.length; attemptNumber++) {
7474
long backoff = ExponentialBackoff.calculateTransactionBackoffMs(attemptNumber);
7575
assertEquals(0, backoff, "With jitter=0, backoff should always be 0 ms");
7676
}

driver-reactive-streams/src/test/functional/com/mongodb/reactivestreams/client/ClientSideOperationTimeoutProseTest.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import com.mongodb.client.model.changestream.FullDocument;
2727
import com.mongodb.event.CommandFailedEvent;
2828
import com.mongodb.event.CommandStartedEvent;
29-
import com.mongodb.internal.time.ExponentialBackoff;
3029
import com.mongodb.reactivestreams.client.gridfs.GridFSBucket;
3130
import com.mongodb.reactivestreams.client.gridfs.GridFSBuckets;
3231
import com.mongodb.reactivestreams.client.syncadapter.SyncGridFSBucket;
@@ -579,15 +578,13 @@ private void assertOnlyOneCommandTimeoutFailure(final String command) {
579578
public void setUp() {
580579
super.setUp();
581580
SyncMongoClient.enableSleepAfterSessionClose(postSessionCloseSleep());
582-
ExponentialBackoff.setTestJitterSupplier(() -> 0);
583581
}
584582

585583
@Override
586584
@AfterEach
587585
public void tearDown() throws InterruptedException {
588586
super.tearDown();
589587
SyncMongoClient.disableSleep();
590-
ExponentialBackoff.clearTestJitterSupplier();
591588
}
592589

593590
@Override

driver-sync/src/test/functional/com/mongodb/client/ClientSideOperationTimeoutProseTest.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import com.mongodb.MongoClientSettings;
2020
import com.mongodb.client.gridfs.GridFSBucket;
2121
import com.mongodb.client.gridfs.GridFSBuckets;
22+
import com.mongodb.internal.time.ExponentialBackoff;
2223

2324

2425
/**
@@ -36,6 +37,22 @@ protected GridFSBucket createGridFsBucket(final MongoDatabase mongoDatabase, fin
3637
return GridFSBuckets.create(mongoDatabase, bucketName);
3738
}
3839

40+
@Override
41+
public void setUp() {
42+
super.setUp();
43+
ExponentialBackoff.setTestJitterSupplier(() -> 0);
44+
}
45+
46+
@Override
47+
public void tearDown() throws InterruptedException {
48+
super.tearDown();
49+
try {
50+
super.tearDown();
51+
} finally {
52+
ExponentialBackoff.clearTestJitterSupplier();
53+
}
54+
}
55+
3956
@Override
4057
protected boolean isAsync() {
4158
return false;

0 commit comments

Comments
 (0)