abhiramaab opened a new pull request, #9311:
URL: https://github.com/apache/hop/pull/9311

   ## Motivation
   
   Fixes #9278.
   
   In `RemoteHopServer.getDelay(int trial, int retryBackoffIncrements)`, the 
upper bound for randomized jitter is calculated as `current / 4L`.
   
   When `retryBackoffIncrements < 4` (e.g., `0, 1, 2, 3`), integer division can 
produce `0`. Passing this value to `Random.nextInt(0)` throws 
`java.lang.IllegalArgumentException: bound must be positive`.
   
   Since `getDelay()` is called inside the `catch` block of `execService(...)` 
during retry handling, this unhandled runtime exception prematurely terminates 
the retry loop on trial 0, masking the original server exception.
   
   ## Modifications
   
   1. Added a guard for `retryBackoffIncrements <= 0`, returning `0` 
immediately.
   2. Added a guard for `jitterBound <= 0` (for increments between 1ms and 
3ms), returning `current` without attempting `Random.nextInt(0)`.
   3. Preserved the existing Fibonacci backoff growth and jitter logic when 
`jitterBound > 0`.
   4. Added boundary test cases in `RemoteHopServerTest.testGetDelay()` 
covering increments `0`, `1`, `2`, `3`, and negative values.
   
   ## Verification
   
   - Executed `mvn test -Dtest=RemoteHopServerTest 
-Dsurefire.failIfNoSpecifiedTests=false -pl engine -am` using OpenJDK 21.
   - All 10 tests in `RemoteHopServerTest` passed.
   
   `Tests run: 10, Failures: 0, Errors: 0, Skipped: 0`


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to