From 99823699822f48b23b0ebf28aff2a638836c88b2 Mon Sep 17 00:00:00 2001 From: Sam Brannen <104798+sbrannen@users.noreply.github.com> Date: Sat, 16 Aug 2025 14:36:09 +0200 Subject: [PATCH] Revise nullability in RetryException See gh-35332 --- .../springframework/core/retry/RetryException.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) 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 f0e490a6917..dbc37772639 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 @@ -19,8 +19,6 @@ 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. * @@ -37,15 +35,18 @@ public class RetryException extends Exception { /** * Create a new {@code RetryException} for the supplied message and cause. * @param message the detail message - * @param cause the root cause + * @param cause the last exception thrown by the {@link Retryable} operation */ public RetryException(String message, Throwable cause) { - super(message, cause); + super(message, Objects.requireNonNull(cause, "cause must not be null")); } + /** + * Get the the last exception thrown by the {@link Retryable} operation. + */ @Override - public synchronized @NonNull Throwable getCause() { + public final synchronized Throwable getCause() { return Objects.requireNonNull(super.getCause()); }