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

DelayExpression not working starting in 2.0.0 #340

Closed
Nivek770 opened this issue May 17, 2023 · 3 comments · Fixed by #341
Closed

DelayExpression not working starting in 2.0.0 #340

Nivek770 opened this issue May 17, 2023 · 3 comments · Fixed by #341
Assignees
Labels
Milestone

Comments

@Nivek770
Copy link

I am working on a Project with Kotlin and Springboot and have run into an issue with the delayExpression value in the @Backoff annotation. It seems like starting at version 2.0.0 any value set will be ignored and instead the default delay of 1000ms will be used.

This is an exerpt from my code:

<dependency>
        <groupId>org.springframework.retry</groupId>
	<artifactId>spring-retry</artifactId>
	<version>2.0.1</version>
</dependency>
@Retryable(
        maxAttemptsExpression = "3",
        backoff = Backoff(delayExpression = "100")
    )
fun myRetryableFunction() {
    //do something
}

As I said, instead of using a delay of 100ms, the default value of 1000ms is used. Simply downgrading the version to 1.3.4 or lower will fix this issue and the delayExpression will be used.

@fengkongling
Copy link

fengkongling commented May 17, 2023 via email

@gaofengIt
Copy link

gaofengIt commented May 17, 2023 via email

@garyrussell
Copy link
Contributor

garyrussell commented May 17, 2023

As a work around use Backoff(delayExpression = "#{100}").

/**
* An expression evaluating to the canonical backoff period. Used as an initial value
* in the exponential case, and as a minimum value in the uniform case. Overrides
* {@link #delay()}. Use {@code #{...}} for one-time evaluation during initialization,
* omit the delimiters for evaluation at runtime.
* @return the initial or canonical backoff period in milliseconds.
* @since 1.2
*/
String delayExpression() default "";

It looks like the runtime evaluation is broken somehow.

With 1.3.x, evaluation was always during initialization, regardless of whether delimiters were provided.

@garyrussell garyrussell added this to the 2.0.2 milestone May 17, 2023
@garyrussell garyrussell self-assigned this May 17, 2023
garyrussell added a commit to garyrussell/spring-retry that referenced this issue May 17, 2023
Resolves spring-projects#340

Runtime evaluation of `delayExpression` with a `FixedBackOffPolicy`
was not implemented causing the expression to be ignored.
artembilan pushed a commit that referenced this issue May 17, 2023
Resolves #340

Runtime evaluation of `delayExpression` with a `FixedBackOffPolicy`
was not implemented causing the expression to be ignored.
kmccarp pushed a commit to kmccarp/spring-projects__spring-retry that referenced this issue Jun 5, 2023
Resolves spring-projects#340

Runtime evaluation of `delayExpression` with a `FixedBackOffPolicy`
was not implemented causing the expression to be ignored.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants