From fcfe975423a8d3bf74b2b63be728936b62c81e2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Zaj=C4=85czkowski?= <148013+szpak@users.noreply.github.com> Date: Wed, 24 Jul 2024 17:36:47 +0200 Subject: [PATCH] Add @Nullable in RetryContext to easier detect possible NPE Both getParent() and getLastThrowable() might return null, as mentioned in javadoc. @Nullable helps an IDE warns developers about potential NPE. --- src/main/java/org/springframework/retry/RetryContext.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/org/springframework/retry/RetryContext.java b/src/main/java/org/springframework/retry/RetryContext.java index 0450ec5c..e367a4af 100644 --- a/src/main/java/org/springframework/retry/RetryContext.java +++ b/src/main/java/org/springframework/retry/RetryContext.java @@ -17,6 +17,7 @@ package org.springframework.retry; import org.springframework.core.AttributeAccessor; +import org.springframework.lang.Nullable; /** * Low-level access to ongoing retry operation. Normally not needed by clients, but can be @@ -85,6 +86,7 @@ public interface RetryContext extends AttributeAccessor { * Accessor for the parent context if retry blocks are nested. * @return the parent or null if there is none. */ + @Nullable RetryContext getParent(); /** @@ -100,6 +102,7 @@ public interface RetryContext extends AttributeAccessor { * if this is the first attempt, but also if the enclosing policy decides not to * provide it (e.g. because of concerns about memory usage). */ + @Nullable Throwable getLastThrowable(); }