Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace raw usages of Attempt #29

Merged
merged 1 commit into from
Jan 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/main/java/org/kiwiproject/retry/StopStrategies.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public static StopStrategy stopAfterDelay(long duration, @Nonnull TimeUnit timeU
@Immutable
private static final class NeverStopStrategy implements StopStrategy {
@Override
public boolean shouldStop(Attempt failedAttempt) {
public boolean shouldStop(Attempt<?> failedAttempt) {
return false;
}
}
Expand All @@ -88,7 +88,7 @@ private static final class StopAfterAttemptStrategy implements StopStrategy {
}

@Override
public boolean shouldStop(Attempt failedAttempt) {
public boolean shouldStop(Attempt<?> failedAttempt) {
return failedAttempt.getAttemptNumber() >= maxAttemptNumber;
}
}
Expand All @@ -103,7 +103,7 @@ private static final class StopAfterDelayStrategy implements StopStrategy {
}

@Override
public boolean shouldStop(Attempt failedAttempt) {
public boolean shouldStop(Attempt<?> failedAttempt) {
return failedAttempt.getDelaySinceFirstAttempt() >= maxDelay;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/kiwiproject/retry/StopStrategy.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ public interface StopStrategy {
* @param failedAttempt the previous failed {@code Attempt}
* @return <code>true</code> if the retryer must stop, <code>false</code> otherwise
*/
boolean shouldStop(Attempt failedAttempt);
boolean shouldStop(Attempt<?> failedAttempt);
}
14 changes: 7 additions & 7 deletions src/main/java/org/kiwiproject/retry/WaitStrategies.java
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ private static final class FixedWaitStrategy implements WaitStrategy {
}

@Override
public long computeSleepTime(Attempt failedAttempt) {
public long computeSleepTime(Attempt<?> failedAttempt) {
return sleepTime;
}
}
Expand All @@ -260,7 +260,7 @@ private static final class RandomWaitStrategy implements WaitStrategy {
}

@Override
public long computeSleepTime(Attempt failedAttempt) {
public long computeSleepTime(Attempt<?> failedAttempt) {
long t = Math.abs(RANDOM.nextLong()) % (maximum - minimum);
return t + minimum;
}
Expand All @@ -279,7 +279,7 @@ private static final class IncrementingWaitStrategy implements WaitStrategy {
}

@Override
public long computeSleepTime(Attempt failedAttempt) {
public long computeSleepTime(Attempt<?> failedAttempt) {
long result = initialSleepTime + (increment * (failedAttempt.getAttemptNumber() - 1));
return result >= 0L ? result : 0L;
}
Expand All @@ -300,7 +300,7 @@ private static final class ExponentialWaitStrategy implements WaitStrategy {
}

@Override
public long computeSleepTime(Attempt failedAttempt) {
public long computeSleepTime(Attempt<?> failedAttempt) {
double exp = Math.pow(2, failedAttempt.getAttemptNumber());
long result = Math.round(multiplier * exp);
if (result > maximumWait) {
Expand All @@ -324,7 +324,7 @@ private static final class FibonacciWaitStrategy implements WaitStrategy {
}

@Override
public long computeSleepTime(Attempt failedAttempt) {
public long computeSleepTime(Attempt<?> failedAttempt) {
long fib = fib(failedAttempt.getAttemptNumber());
long result = multiplier * fib;

Expand Down Expand Up @@ -363,7 +363,7 @@ private static final class CompositeWaitStrategy implements WaitStrategy {
}

@Override
public long computeSleepTime(Attempt failedAttempt) {
public long computeSleepTime(Attempt<?> failedAttempt) {
long waitTime = 0L;
for (WaitStrategy waitStrategy : waitStrategies) {
waitTime += waitStrategy.computeSleepTime(failedAttempt);
Expand All @@ -384,7 +384,7 @@ private static final class ExceptionWaitStrategy<T extends Throwable> implements

@SuppressWarnings({"unchecked"})
@Override
public long computeSleepTime(Attempt lastAttempt) {
public long computeSleepTime(Attempt<?> lastAttempt) {
if (lastAttempt.hasException()) {
Throwable cause = lastAttempt.getException();
if (exceptionClass.isAssignableFrom(cause.getClass())) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/kiwiproject/retry/WaitStrategy.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ public interface WaitStrategy {
* @param failedAttempt the previous failed {@code Attempt}
* @return the sleep time before next attempt
*/
long computeSleepTime(Attempt failedAttempt);
long computeSleepTime(Attempt<?> failedAttempt);
}