You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@james.apache.org by bt...@apache.org on 2026/01/13 14:49:04 UTC

(james-project) 08/09: Small fix for WaitDelay generator

This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit b1dec0431cf4cf5f9865ae033e23a065c98638fe
Author: Benoit TELLIER <bt...@linagora.com>
AuthorDate: Thu Jan 8 09:40:05 2026 +0100

    Small fix for WaitDelay generator
---
 .../src/main/java/org/apache/james/events/WaitDelayGenerator.java     | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/event-bus/distributed/src/main/java/org/apache/james/events/WaitDelayGenerator.java b/event-bus/distributed/src/main/java/org/apache/james/events/WaitDelayGenerator.java
index e12eb65716..01f23b010b 100644
--- a/event-bus/distributed/src/main/java/org/apache/james/events/WaitDelayGenerator.java
+++ b/event-bus/distributed/src/main/java/org/apache/james/events/WaitDelayGenerator.java
@@ -37,10 +37,10 @@ class WaitDelayGenerator {
 
     private static Duration randomBetween(Duration base, Duration jitter) {
         Preconditions.checkArgument(!jitter.isNegative(), "jitter value should always be positive");
-        if (jitter.isZero()) {
+        long maxJitterAsMillis = jitter.toMillis();
+        if (maxJitterAsMillis <= 0) {
             return base;
         }
-        long maxJitterAsMillis = jitter.toMillis();
         long jitterAsMillis = SECURE_RANDOM.nextInt(Ints.checkedCast(maxJitterAsMillis * 2)) / 2;
         return base.plusMillis(jitterAsMillis);
     }


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org