Skip to content

maxAttemptsExpression is not evaluated when an exceptionExpression is set #383

Closed
@shubhgup11

Description

@shubhgup11

@retryable doesnt seem to evaluate maxAttemptsExpression while creating the retryTemplate, if it has an exceptionExpression

This piece of code in AnnotationAwareRetryOperationsInterceptor.java should be modified i guess .

if (simple == null) {
			if (hasExpression) {
				simple = new ExpressionRetryPolicy(maxAttempts, policyMap, true, resolve(exceptionExpression),
						retryNotExcluded)
					.withBeanFactory(this.beanFactory);
			}
			else {
				simple = new SimpleRetryPolicy(maxAttempts, policyMap, true, retryNotExcluded);
				if (expression != null) {
					simple.maxAttemptsSupplier(() -> evaluate(expression, Integer.class, stateless));
				}
			}
		}

The maxAttempts supplies should be evaluated no matter , exceptionExpression is present or not.

This should be like this maybe

if (simple == null) {
			if (hasExpression) {
				simple = new ExpressionRetryPolicy(maxAttempts, policyMap, true, resolve(exceptionExpression),
						retryNotExcluded)
					.withBeanFactory(this.beanFactory);
			}
			else {
				simple = new SimpleRetryPolicy(maxAttempts, policyMap, true, retryNotExcluded);
			}
if (expression != null) {
					simple.maxAttemptsSupplier(() -> evaluate(expression, Integer.class, stateless));
				}
		}

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions