Skip to content

Commit

Permalink
Add @nullable in RetryContext to easier detect possible NPE
Browse files Browse the repository at this point in the history
Both getParent() and getLastThrowable() might return null, as mentioned
in javadoc. @nullable helps an IDE warns developers about potential NPE.
  • Loading branch information
szpak committed Jul 24, 2024
1 parent a9b329a commit b8e75f7
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/main/java/org/springframework/retry/RetryContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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();

/**
Expand All @@ -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();

}

0 comments on commit b8e75f7

Please sign in to comment.