Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UniformRandomBackOffPolicy is throwing IllegalArgumentException on calling backOff when maxBackOffPeriod is less than minBackOffPeriod. #464

Closed
LokeshAlamuri opened this issue Aug 31, 2024 · 1 comment
Labels
Milestone

Comments

@LokeshAlamuri
Copy link
Contributor

Scenario:

UniformRandomBackOffPolicy is throwing IllegalArgumentException on calling backOff when maxBackOffPeriod is less than minBackOffPeriod.

Version Tested:

2.0.9

Junit to Replicate::

maxBackOff < minBackOff

@Test
public void testMaxBackOffLessThanMinBackOff() {
	UniformRandomBackOffPolicy backOffPolicy = new UniformRandomBackOffPolicy();
	int minBackOff = 1000;
	int maxBackOff = 10;
	backOffPolicy.setMinBackOffPeriod(minBackOff);
	backOffPolicy.setMaxBackOffPeriod(maxBackOff);
	UniformRandomBackOffPolicy withSleeper = backOffPolicy.withSleeper(new Sleeper() {
		@Override
		public void sleep(long backOffPeriod) throws InterruptedException {
			// do nothing;
		}
	});

	assertThatExceptionOfType(IllegalArgumentException.class).isThrownBy(() -> withSleeper.backOff(null));
}

Possible fix:

Following scenarios are addressed when the UniformRandomBackOffPolicy is not configured properly.

  1. maxBackOff is less than or equal to zero.
  2. minackOff is less than or equal to zero.
  3. maxBackOff is equal to minBackOff.

Similarly, when maxBackOff is less than minBackOff could be validated and provide some default value.

@LokeshAlamuri
Copy link
Contributor Author

Please review the following PR to fix the reported issue. Please give your comments.
#465

@artembilan artembilan added this to the 2.0.9 milestone Sep 3, 2024
@artembilan artembilan added the bug label Sep 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants