File tree Expand file tree Collapse file tree 1 file changed +3
-1
lines changed
driver-core/src/main/com/mongodb/internal/time Expand file tree Collapse file tree 1 file changed +3
-1
lines changed Original file line number Diff line number Diff line change 2121import java .util .concurrent .ThreadLocalRandom ;
2222import java .util .function .DoubleSupplier ;
2323
24+ import static com .mongodb .assertions .Assertions .assertTrue ;
2425import 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 ();
You can’t perform that action at this time.
0 commit comments