Skip to content

Commit 9df8d6c

Browse files
authored
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
1 parent a9b329a commit 9df8d6c

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/main/java/org/springframework/retry/RetryContext.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,15 @@
1717
package org.springframework.retry;
1818

1919
import org.springframework.core.AttributeAccessor;
20+
import org.springframework.lang.Nullable;
2021

2122
/**
2223
* Low-level access to ongoing retry operation. Normally not needed by clients, but can be
2324
* used to alter the course of the retry, e.g. force an early termination.
2425
*
2526
* @author Dave Syer
2627
* @author Emanuele Ivaldi
28+
* @author Marcin Zajączkowski
2729
*
2830
*/
2931
public interface RetryContext extends AttributeAccessor {
@@ -85,6 +87,7 @@ public interface RetryContext extends AttributeAccessor {
8587
* Accessor for the parent context if retry blocks are nested.
8688
* @return the parent or null if there is none.
8789
*/
90+
@Nullable
8891
RetryContext getParent();
8992

9093
/**
@@ -97,9 +100,11 @@ public interface RetryContext extends AttributeAccessor {
97100
/**
98101
* Accessor for the exception object that caused the current retry.
99102
* @return the last exception that caused a retry, or possibly null. It will be null
100-
* if this is the first attempt, but also if the enclosing policy decides not to
101-
* provide it (e.g. because of concerns about memory usage).
103+
* if this is the first attempt and it finishes successfully, but also if the
104+
* enclosing policy decides not to provide it (e.g. because of concerns about memory
105+
* usage).
102106
*/
107+
@Nullable
103108
Throwable getLastThrowable();
104109

105110
}

0 commit comments

Comments
 (0)