Skip to content

Commit

Permalink
Remove redundant get() method from Attempt (#51)
Browse files Browse the repository at this point in the history
* Remove get() and leave getResult()

Closes #50
  • Loading branch information
sleberknight authored Jan 22, 2021
1 parent a968bd6 commit 8482124
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 15 deletions.
17 changes: 3 additions & 14 deletions src/main/java/org/kiwiproject/retry/Attempt.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,6 @@ public class Attempt<T> {
this.delaySinceFirstAttempt = delaySinceFirstAttempt;
}

/**
* Returns the result of the attempt, if any.
*
* @return the result of the attempt
* @throws IllegalStateException If the attempt resulted in an exception rather
* than returning a result.
*/
public T get() {
checkState(hasResult(), "The attempt resulted in an exception, not in a result");
return result;
}

/**
* Tells if the call returned a result or not
*
Expand All @@ -88,12 +76,13 @@ public boolean hasException() {
/**
* Gets the result of the call
*
* @return the result of the call
* @return the result of the call (may be {@code null})
* @throws IllegalStateException if the call didn't return a result, but threw an exception,
* as indicated by {@link #hasResult()}
*/
public T getResult() {
return get();
checkState(hasResult(), "The attempt resulted in an exception, not in a result");
return result;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/kiwiproject/retry/Retryer.java
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ private <T> T getOrThrow(Attempt<T> attempt) throws RetryException {
if (attempt.hasException()) {
throw new RetryException(attempt);
}
return attempt.get();
return attempt.getResult();
}

/**
Expand Down

0 comments on commit 8482124

Please sign in to comment.