diff --git a/spring-context/src/main/java/org/springframework/resilience/retry/AbstractRetryInterceptor.java b/spring-context/src/main/java/org/springframework/resilience/retry/AbstractRetryInterceptor.java index 65942411546..762c5612f42 100644 --- a/spring-context/src/main/java/org/springframework/resilience/retry/AbstractRetryInterceptor.java +++ b/spring-context/src/main/java/org/springframework/resilience/retry/AbstractRetryInterceptor.java @@ -112,8 +112,7 @@ public abstract class AbstractRetryInterceptor implements MethodInterceptor { }); } catch (RetryException ex) { - Throwable cause = ex.getCause(); - throw (cause != null ? cause : new IllegalStateException(ex.getMessage(), ex)); + throw ex.getCause(); } } diff --git a/spring-core/src/main/java/org/springframework/core/retry/RetryException.java b/spring-core/src/main/java/org/springframework/core/retry/RetryException.java index d9c0f34e275..f0e490a6917 100644 --- a/spring-core/src/main/java/org/springframework/core/retry/RetryException.java +++ b/spring-core/src/main/java/org/springframework/core/retry/RetryException.java @@ -17,6 +17,9 @@ package org.springframework.core.retry; import java.io.Serial; +import java.util.Objects; + +import org.jspecify.annotations.NonNull; /** * Exception thrown when a {@link RetryPolicy} has been exhausted. @@ -31,14 +34,6 @@ public class RetryException extends Exception { private static final long serialVersionUID = 5439915454935047936L; - /** - * Create a new {@code RetryException} for the supplied message. - * @param message the detail message - */ - public RetryException(String message) { - super(message); - } - /** * Create a new {@code RetryException} for the supplied message and cause. * @param message the detail message @@ -48,4 +43,10 @@ public class RetryException extends Exception { super(message, cause); } + + @Override + public synchronized @NonNull Throwable getCause() { + return Objects.requireNonNull(super.getCause()); + } + }