From bded8e67df3a0b5bd2763f2a03720e61b7a72af8 Mon Sep 17 00:00:00 2001 From: Artem Bilan Date: Thu, 27 Mar 2025 14:29:01 -0400 Subject: [PATCH] GH-488: Improve warning in the `ExpressionRetryPolicy` Fixes: https://github.com/spring-projects/spring-retry/issues/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 --- .../retry/policy/ExpressionRetryPolicy.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/springframework/retry/policy/ExpressionRetryPolicy.java b/src/main/java/org/springframework/retry/policy/ExpressionRetryPolicy.java index 093da6c..9ab7a1c 100644 --- a/src/main/java/org/springframework/retry/policy/ExpressionRetryPolicy.java +++ b/src/main/java/org/springframework/retry/policy/ExpressionRetryPolicy.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-2019 the original author or authors. + * Copyright 2015-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -37,6 +37,7 @@ import org.springframework.util.Assert; * * @author Gary Russell * @author Aldo Sinanaj + * @author Artem Bilan * @since 1.2 * */ @@ -128,8 +129,9 @@ public class ExpressionRetryPolicy extends SimpleRetryPolicy implements BeanFact */ private static Expression getExpression(String expression) { if (isTemplate(expression)) { - logger.warn("#{...} syntax is not required for this run-time expression " - + "and is deprecated in favor of a simple expression string"); + logger.warn("#{...} syntax is not required for run-time expression in this policy " + + "and is deprecated in favor of a simple expression string." + + "Consider to remove SpEL template tokens around expression: '" + expression + "'"); return new SpelExpressionParser().parseExpression(expression, PARSER_CONTEXT); } return new SpelExpressionParser().parseExpression(expression);