Description
Discussed in #291
Originally posted by evgenvi April 20, 2022
The evaluationContext is passed when parsing all the expression parameters of Retryable
and Backoff
annotations except for CircuitBreaker
annotation in AnnotationAwareRetryOperationsInterceptor
.
For example, it's passed when parsing delayExpression parameter:
PARSER.parseExpression(resolve(delayExpression),PARSER_CONTEXT) .getValue(this.evaluationContext, Long.class);
For example, it isn't passed when parsing openTimeoutExpression parameter:
PARSER.parseExpression(resolve(circuit.openTimeoutExpression()), PARSER_CONTEXT) .getValue(Long.class);
if we try to resolve this snippet of code:
public static class Configs {
public int maxAttempts = 10;
public long openTimeout = 10000;
public long resetTimeout = 10000;
}
@Bean
public Configs configs() {
return new Configs();
}
@Component
public static class Service {
@CircuitBreaker(
maxAttemptsExpression = "#{@configs.maxAttempts}",
openTimeoutExpression = "#{@configs.openTimeout}",
resetTimeoutExpression = "#{@configs.resetTimeout}"
)
public String method() {
return "value";
}
}
The only maxAttempts
parameter will be resolved correctly and we will get an exception for the other two parameters
org.springframework.expression.spel.SpelEvaluationException: EL1057E: No bean resolver registered in the context to resolve access to bean 'configs'
@garyrussell could you tell me if there is any reason why the evaluation context isn't passed when parsing expressions for CircuitBreaker properties?