-
Notifications
You must be signed in to change notification settings - Fork 532
Description
An annotation like this
@Retryable(maxAttemptsExpression = "${application.config.maxRetryAttempts}",
backoff = @Backoff(delayExpression = "${application.config.retryDelayTimeMs}"),
retryFor = {MyRetryableException.class})
public void myMethod(){
...
}
does not result in a backoff delay pulled from the delayExpression as intended, but rather uses the default delay of 1000ms.
Debugging through the code, BackoffPolicyBuilder.build()
correctly receives the delaySupplier with the value pulled from ${application.config.retryDelayTimeMs}
, but only applies this field if a multiplier is present, or if a maxDelay is specified. If neither of these are true, then a FixedBackoffPolicy is instantiated, populated with the default delay of 1000ms and a sleeper, and returned.
FixedBackoffPolicy can support a backoff period supplier, but none is set in the BackoffPolicyBuilder.build()
method.
This can be worked around by adding a multiplier of 1, or by adding a maxDelay to the backoff annotation, thus directing the BackoffPolicyBuilder
to the sections of the build()
method that take into account the delay expression. However, seems like a FixedBackoffPolicy
can be generated that uses the specified delay expression, without having to set these other annotation attributes.