From 9df8d6cc90a06b71fe733697b91adcf5431da215 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Zaj=C4=85czkowski?= <148013+szpak@users.noreply.github.com> Date: Thu, 25 Jul 2024 23:28:04 +0200 Subject: [PATCH] Add @Nullable in RetryContext to easier detect possible NPE * 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. * Rephrase Javadoc for RetryContext.getLastThrowable() * Review fixes --- .../java/org/springframework/retry/RetryContext.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/springframework/retry/RetryContext.java b/src/main/java/org/springframework/retry/RetryContext.java index 0450ec5..167d07c 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 @@ -24,6 +25,7 @@ import org.springframework.core.AttributeAccessor; * * @author Dave Syer * @author Emanuele Ivaldi + * @author Marcin ZajÄ…czkowski * */ public interface RetryContext extends AttributeAccessor { @@ -85,6 +87,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(); /** @@ -97,9 +100,11 @@ public interface RetryContext extends AttributeAccessor { /** * Accessor for the exception object that caused the current retry. * @return the last exception that caused a retry, or possibly null. It will be null - * 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). + * if this is the first attempt and it finishes successfully, but also if the + * enclosing policy decides not to provide it (e.g. because of concerns about memory + * usage). */ + @Nullable Throwable getLastThrowable(); }