Skip to content

Commit c97073e

Browse files
committed
PR feedback
1 parent ddfe918 commit c97073e

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

driver-core/src/main/com/mongodb/internal/time/ExponentialBackoff.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import java.util.concurrent.ThreadLocalRandom;
2222
import java.util.function.DoubleSupplier;
2323

24+
import static com.mongodb.assertions.Assertions.assertTrue;
2425
import static com.mongodb.internal.VisibleForTesting.AccessModifier.PRIVATE;
2526

2627
/**
@@ -42,10 +43,11 @@ private ExponentialBackoff() {
4243
/**
4344
* Calculate the backoff in milliseconds for transaction retries.
4445
*
45-
* @param attemptNumber The attempt number
46+
* @param attemptNumber 0-based attempt number
4647
* @return The calculated backoff in milliseconds.
4748
*/
4849
public static long calculateTransactionBackoffMs(final int attemptNumber) {
50+
assertTrue(attemptNumber > 0, "Attempt number must be greater than 0 in the context of transaction backoff calculation");
4951
double jitter = testJitterSupplier != null
5052
? testJitterSupplier.getAsDouble()
5153
: ThreadLocalRandom.current().nextDouble();

0 commit comments

Comments
 (0)