From 8482124b539bc485dce9dabb0395b95c0a0a8435 Mon Sep 17 00:00:00 2001 From: Scott Leberknight <174812+sleberknight@users.noreply.github.com> Date: Fri, 22 Jan 2021 10:03:20 -0500 Subject: [PATCH] Remove redundant get() method from Attempt (#51) * Remove get() and leave getResult() Closes #50 --- .../java/org/kiwiproject/retry/Attempt.java | 17 +++-------------- .../java/org/kiwiproject/retry/Retryer.java | 2 +- 2 files changed, 4 insertions(+), 15 deletions(-) diff --git a/src/main/java/org/kiwiproject/retry/Attempt.java b/src/main/java/org/kiwiproject/retry/Attempt.java index c6e74ea..e08525a 100644 --- a/src/main/java/org/kiwiproject/retry/Attempt.java +++ b/src/main/java/org/kiwiproject/retry/Attempt.java @@ -51,18 +51,6 @@ public class Attempt { 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 * @@ -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; } /** diff --git a/src/main/java/org/kiwiproject/retry/Retryer.java b/src/main/java/org/kiwiproject/retry/Retryer.java index 77f9fb9..8d2e6c8 100644 --- a/src/main/java/org/kiwiproject/retry/Retryer.java +++ b/src/main/java/org/kiwiproject/retry/Retryer.java @@ -156,7 +156,7 @@ private T getOrThrow(Attempt attempt) throws RetryException { if (attempt.hasException()) { throw new RetryException(attempt); } - return attempt.get(); + return attempt.getResult(); } /**