Skip to content

Commit bded8e6

Browse files
committed
GH-488: Improve warning in the ExpressionRetryPolicy
Fixes: #488 When `@Retryable(exceptionExpression)` is used with SpEL template (`#{..}`), a specific warning is emitted into logs indicating that such a syntax is deprecated. * Improve that warning message pointing out what SpEL expression could be improved to avoid this warning and future changes
1 parent 4f34e36 commit bded8e6

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/main/java/org/springframework/retry/policy/ExpressionRetryPolicy.java

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2015-2019 the original author or authors.
2+
* Copyright 2015-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -37,6 +37,7 @@
3737
*
3838
* @author Gary Russell
3939
* @author Aldo Sinanaj
40+
* @author Artem Bilan
4041
* @since 1.2
4142
*
4243
*/
@@ -128,8 +129,9 @@ public boolean canRetry(RetryContext context) {
128129
*/
129130
private static Expression getExpression(String expression) {
130131
if (isTemplate(expression)) {
131-
logger.warn("#{...} syntax is not required for this run-time expression "
132-
+ "and is deprecated in favor of a simple expression string");
132+
logger.warn("#{...} syntax is not required for run-time expression in this policy "
133+
+ "and is deprecated in favor of a simple expression string." +
134+
"Consider to remove SpEL template tokens around expression: '" + expression + "'");
133135
return new SpelExpressionParser().parseExpression(expression, PARSER_CONTEXT);
134136
}
135137
return new SpelExpressionParser().parseExpression(expression);

0 commit comments

Comments
 (0)