This is an automated email from the ASF dual-hosted git repository.
hansva pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/hop.git
The following commit(s) were added to refs/heads/main by this push:
new 0cc04a134a Fixes #9278: Prevent IllegalArgumentException when retry
backoff increments below 4 (#9311)
0cc04a134a is described below
commit 0cc04a134ac999434d281b2874e61a5fcd667f0c
Author: Abhirama <[email protected]>
AuthorDate: Fri Nov 6 13:32:54 2026 +0530
Fixes #9278: Prevent IllegalArgumentException when retry backoff increments
below 4 (#9311)
---
engine/src/main/java/org/apache/hop/www/RemoteHopServer.java | 9 ++++++++-
engine/src/test/java/org/apache/hop/www/RemoteHopServerTest.java | 7 +++++++
2 files changed, 15 insertions(+), 1 deletion(-)
diff --git a/engine/src/main/java/org/apache/hop/www/RemoteHopServer.java
b/engine/src/main/java/org/apache/hop/www/RemoteHopServer.java
index e879c50690..f9482192af 100644
--- a/engine/src/main/java/org/apache/hop/www/RemoteHopServer.java
+++ b/engine/src/main/java/org/apache/hop/www/RemoteHopServer.java
@@ -459,6 +459,9 @@ public class RemoteHopServer {
}
public static long getDelay(int trial, int retryBackoffIncrements) {
+ if (retryBackoffIncrements <= 0) {
+ return 0;
+ }
long current = retryBackoffIncrements;
long previous = 0;
for (int i = 0; i < trial; i++) {
@@ -466,7 +469,11 @@ public class RemoteHopServer {
current = current + previous;
previous = tmp;
}
- return current + RANDOM.nextInt((int) Math.min(Integer.MAX_VALUE, current
/ 4L));
+ long jitterBound = current / 4L;
+ if (jitterBound <= 0) {
+ return current;
+ }
+ return current + RANDOM.nextInt((int) Math.min(Integer.MAX_VALUE,
jitterBound));
}
public String execService(IVariables variables, String service) throws
Exception {
diff --git a/engine/src/test/java/org/apache/hop/www/RemoteHopServerTest.java
b/engine/src/test/java/org/apache/hop/www/RemoteHopServerTest.java
index 64abc3c541..c94c33dc41 100644
--- a/engine/src/test/java/org/apache/hop/www/RemoteHopServerTest.java
+++ b/engine/src/test/java/org/apache/hop/www/RemoteHopServerTest.java
@@ -309,6 +309,13 @@ class RemoteHopServerTest {
@Test
void testGetDelay() {
+ // boundary cases with increments < 4 must not throw
IllegalArgumentException
+ assertEquals(0, RemoteHopServer.getDelay(0, 0));
+ assertEquals(0, RemoteHopServer.getDelay(2, -1));
+ assertEquals(1, RemoteHopServer.getDelay(0, 1));
+ assertEquals(2, RemoteHopServer.getDelay(0, 2));
+ assertEquals(3, RemoteHopServer.getDelay(0, 3));
+
// first attempt: backoff + a jitter of at most backoff/4
assertTrue(RemoteHopServer.getDelay(0, 1000) >= 1000);
assertTrue(RemoteHopServer.getDelay(0, 1000) < 1250);