failsafe-lib/failsafe

RetryPolicyConfig.getDelayMin returning null when only withDelay() is used

MalikKillian opened this issue · 1 comments

Failsafe documentation describes the behavior of RetryPolicyConfig.getDelayMin as:

Returns the min delay between retries.

When the delay is set using the withDelay method the min delay is set to [and returns] null. The behavior is the same for the max delay.

Conventional thinking would imply that a fixed delay would result in the min and max delay becoming the same value.

A small code snippet to reproduce the behavior:

    RetryPolicy<Integer> policy = RetryPolicy.<Integer>builder()
      .withDelay(Duration.ofSeconds(1), Duration.ofSeconds(2)).build();
    policy.getConfig().getDelayMin().getSeconds();  // No issues
    policy.getConfig().getDelayMax().getSeconds();  // No issues
    policy.getConfig().getDelay().getSeconds();     // No issues (although this is zero)

    policy = RetryPolicy.<Integer>builder()
      .withDelay(Duration.ofSeconds(1)).build();
    policy.getConfig().getDelayMin()                // This is null
      .getSeconds();                                // NullPointerException

I think the docs should be updated to specify that min and max only exist if min and max are explicitly set OR (my preference) the use of withDelay should result in delayMax and delayMin being set to the same value.

Thanks for raising this. I pushed an improvement to the docs.