Skip to content

Commit 4da9dda

Browse files
committed
Warning free build on java-8. Corrected javadoc.
1 parent a0e4b57 commit 4da9dda

File tree

8 files changed

+31
-0
lines changed

8 files changed

+31
-0
lines changed

src/main/java/com/github/rholder/retry/AttemptTimeLimiter.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ public interface AttemptTimeLimiter<V> {
2828
/**
2929
* @param callable to subject to the time limit
3030
* @return the return of the given callable
31+
* @throws java.lang.Exception All exceptions that can happen because of this invocation.
3132
*/
3233
V call(Callable<V> callable) throws Exception;
3334
}

src/main/java/com/github/rholder/retry/AttemptTimeLimiters.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ private AttemptTimeLimiters(){
3636
}
3737

3838
/**
39+
* @param <V> The type of the computation result.
3940
* @return an {@link AttemptTimeLimiter} impl which has no time limit
4041
*/
4142
public static <V> AttemptTimeLimiter<V> noTimeLimit() {
@@ -48,6 +49,7 @@ public static <V> AttemptTimeLimiter<V> noTimeLimit() {
4849
* {@link SimpleTimeLimiter#SimpleTimeLimiter(ExecutorService)}, which this AttemptTimeLimiter uses.
4950
* @param duration that an attempt may persist before being circumvented
5051
* @param timeUnit of the 'duration' arg
52+
* @param <V> The type of the computation result.
5153
* @return an {@link AttemptTimeLimiter} with a fixed time limit for each attempt
5254
*/
5355
public static <V> AttemptTimeLimiter<V> fixedTimeLimit(long duration, @Nonnull TimeUnit timeUnit) {
@@ -59,6 +61,7 @@ public static <V> AttemptTimeLimiter<V> fixedTimeLimit(long duration, @Nonnull T
5961
* @param duration that an attempt may persist before being circumvented
6062
* @param timeUnit of the 'duration' arg
6163
* @param executorService used to enforce time limit
64+
* @param <V> The type of the computation result.
6265
* @return an {@link AttemptTimeLimiter} with a fixed time limit for each attempt
6366
*/
6467
public static <V> AttemptTimeLimiter<V> fixedTimeLimit(long duration, @Nonnull TimeUnit timeUnit, @Nonnull ExecutorService executorService) {

src/main/java/com/github/rholder/retry/RetryException.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,15 @@ public RetryException(String message, int numberOfFailedAttempts, Attempt<?> las
6161

6262
/**
6363
* Returns the number of failed attempts
64+
* @return Gets the number of failed attempts
6465
*/
6566
public int getNumberOfFailedAttempts() {
6667
return numberOfFailedAttempts;
6768
}
6869

6970
/**
7071
* Returns the last failed attempt
72+
* @return The last failed attempt.
7173
*/
7274
public Attempt<?> getLastFailedAttempt() {
7375
return lastFailedAttempt;

src/main/java/com/github/rholder/retry/Retryer.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ public Retryer(@Nonnull AttemptTimeLimiter<V> attemptTimeLimiter,
8989
* accepts the attempt, the stop strategy is used to decide if a new attempt
9090
* must be made. Then the wait strategy is used to decide how must time to sleep,
9191
* and a new attempt is made.
92+
* @param callable The callable task which need to be executed.
93+
* @return The computed result of the given callable.
9294
* @throws ExecutionException if the given callable throws an exception, and the
9395
* rejection predicate considers the attempt as successful. The original exception
9496
* is wrapped into an ExecutionException.
@@ -128,6 +130,7 @@ public V call(Callable<V> callable) throws ExecutionException, RetryException {
128130
* Wraps the given callable into a {@link RetryerCallable}, which can be submitted to an executor.
129131
* The returned callable will use this retryer to call the given callable
130132
* @param callable the callable to wrap
133+
* @return A {@link RetryerCallable} containing and retryer and a callable.
131134
*/
132135
public RetryerCallable<V> wrap(Callable<V> callable) {
133136
return new RetryerCallable<V>(this, callable);

src/main/java/com/github/rholder/retry/RetryerBuilder.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ private RetryerBuilder() {
4040

4141
/**
4242
* Constructs a new builder
43+
* @param <V> The type of result, the callable task is supposed to return.
4344
* @return the new builder
4445
*/
4546
public static <V> RetryerBuilder<V> newBuilder() {

src/main/java/com/github/rholder/retry/StopStrategies.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ private StopStrategies() {
3232

3333
/**
3434
* Returns a stop strategy which consists in never stopping retrying
35+
* @return A stop strategy which never stops.
3536
*/
3637
public static StopStrategy neverStop() {
3738
return NEVER_STOP;
@@ -40,6 +41,7 @@ public static StopStrategy neverStop() {
4041
/**
4142
* Returns a stop strategy which consists in stopping after N failed attempts
4243
* @param attemptNumber the number of failed attempts before stopping
44+
* @return A stop strategy which stops after {@code attemptNumber} attempts
4345
*/
4446
public static StopStrategy stopAfterAttempt(int attemptNumber) {
4547
return new StopAfterAttemptStrategy(attemptNumber);
@@ -48,6 +50,7 @@ public static StopStrategy stopAfterAttempt(int attemptNumber) {
4850
/**
4951
* Returns a stop strategy which consists in stopping after a given delay
5052
* @param delayInMillis the delay, in milliseconds, starting with the start of the first attempt.
53+
* @return A stop strategy which stops after {@code delayInMillis} time in milli seconds.
5154
*/
5255
public static StopStrategy stopAfterDelay(long delayInMillis) {
5356
return new StopAfterDelayStrategy(delayInMillis);

src/main/java/com/github/rholder/retry/WaitStrategies.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ private WaitStrategies() {
3636

3737
/**
3838
* Returns a strategy that doesn't sleep at all before retrying.
39+
* @return A wait strategy which doesn't wait between retries
3940
*/
4041
public static WaitStrategy noWait() {
4142
return NO_WAIT_STRATEGY;
@@ -46,6 +47,7 @@ public static WaitStrategy noWait() {
4647
*
4748
* @param sleepTime the time to sleep
4849
* @param timeUnit the unit of the time to sleep
50+
* @return A wait strategy with fixed {@code sleepTime}
4951
* @throws IllegalStateException if the sleep time is &lt; 0.
5052
*/
5153
public static WaitStrategy fixedWait(long sleepTime, @Nonnull TimeUnit timeUnit) throws IllegalStateException {
@@ -58,6 +60,7 @@ public static WaitStrategy fixedWait(long sleepTime, @Nonnull TimeUnit timeUnit)
5860
*
5961
* @param maximumTime the maximum time to sleep
6062
* @param timeUnit the unit of the maximum time
63+
* @return A wait strategy with random wait time
6164
* @throws IllegalStateException if the maximum sleep time is &lt;= 0.
6265
*/
6366
public static WaitStrategy randomWait(long maximumTime, @Nonnull TimeUnit timeUnit) {
@@ -72,6 +75,7 @@ public static WaitStrategy randomWait(long maximumTime, @Nonnull TimeUnit timeUn
7275
* @param minimumTimeUnit the unit of the minimum time
7376
* @param maximumTime the maximum time to sleep
7477
* @param maximumTimeUnit the unit of the maximum time
78+
* @return A wait strategy with random wait time
7579
* @throws IllegalStateException if the minimum sleep time is &lt; 0, or if the
7680
* maximum sleep time is less than (or equals to) the minimum.
7781
*/
@@ -94,6 +98,7 @@ public static WaitStrategy randomWait(long minimumTime,
9498
* @param initialSleepTimeUnit the unit of the initial sleep time
9599
* @param increment the increment added to the previous sleep time after each failed attempt
96100
* @param incrementTimeUnit the unit of the increment
101+
* @return A wait strategy with wait time following the incremental pattern.
97102
*/
98103
public static WaitStrategy incrementingWait(long initialSleepTime,
99104
@Nonnull TimeUnit initialSleepTimeUnit,
@@ -108,6 +113,8 @@ public static WaitStrategy incrementingWait(long initialSleepTime,
108113
/**
109114
* Returns a strategy which sleeps for an exponential amount of time after the first failed attempt,
110115
* and in exponentially incrementing amounts after each failed attempt up to Long.MAX_VALUE.
116+
*
117+
* @return A wait strategy with wait time following the exponential pattern.
111118
*/
112119
public static WaitStrategy exponentialWait() {
113120
return new ExponentialWaitStrategy(1, Long.MAX_VALUE);
@@ -119,6 +126,7 @@ public static WaitStrategy exponentialWait() {
119126
*
120127
* @param maximumTime the maximum time to sleep
121128
* @param maximumTimeUnit the unit of the maximum time
129+
* @return A wait strategy with wait time following the exponential pattern.
122130
*/
123131
public static WaitStrategy exponentialWait(long maximumTime,
124132
@Nonnull TimeUnit maximumTimeUnit) {
@@ -129,10 +137,13 @@ public static WaitStrategy exponentialWait(long maximumTime,
129137
/**
130138
* Returns a strategy which sleeps for an exponential amount of time after the first failed attempt,
131139
* and in exponentially incrementing amounts after each failed attempt up to the maximumTime.
140+
* The wait time between the retries can be controlled by the multiplier.
141+
* nextWaitTime = exponentialIncrement * {@code multiplier}.
132142
*
133143
* @param multiplier multiply the wait time calculated by this
134144
* @param maximumTime the maximum time to sleep
135145
* @param maximumTimeUnit the unit of the maximum time
146+
* @return A wait strategy with wait time following the exponential pattern.
136147
*/
137148
public static WaitStrategy exponentialWait(long multiplier,
138149
long maximumTime,
@@ -144,6 +155,8 @@ public static WaitStrategy exponentialWait(long multiplier,
144155
/**
145156
* Returns a strategy which sleeps for an increasing amount of time after the first failed attempt,
146157
* and in Fibonacci increments after each failed attempt up to {@link Long#MAX_VALUE}.
158+
*
159+
* @return A wait strategy with wait time following the fibonacci pattern.
147160
*/
148161
public static WaitStrategy fibonacciWait() {
149162
return new FibonacciWaitStrategy(1, Long.MAX_VALUE);
@@ -155,6 +168,7 @@ public static WaitStrategy fibonacciWait() {
155168
*
156169
* @param maximumTime the maximum time to sleep
157170
* @param maximumTimeUnit the unit of the maximum time
171+
* @return A wait strategy with wait time following the fibonacci pattern.
158172
*/
159173
public static WaitStrategy fibonacciWait(long maximumTime,
160174
@Nonnull TimeUnit maximumTimeUnit) {
@@ -165,10 +179,13 @@ public static WaitStrategy fibonacciWait(long maximumTime,
165179
/**
166180
* Returns a strategy which sleeps for an increasing amount of time after the first failed attempt,
167181
* and in Fibonacci increments after each failed attempt up to the {@code maximumTime}.
182+
* The wait time between the retries can be controlled by the multiplier.
183+
* nextWaitTime = fibonacciIncrement * {@code multiplier}.
168184
*
169185
* @param multiplier multiply the wait time calculated by this
170186
* @param maximumTime the maximum time to sleep
171187
* @param maximumTimeUnit the unit of the maximum time
188+
* @return A wait strategy with wait time following the fibonacci pattern.
172189
*/
173190
public static WaitStrategy fibonacciWait(long multiplier,
174191
long maximumTime,

src/main/java/com/github/rholder/retry/WaitStrategy.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ public interface WaitStrategy {
2626
* Returns the time, in milliseconds, to sleep before retrying.
2727
* @param previousAttemptNumber the number, starting from 1, of the previous (failed) attempt
2828
* @param delaySinceFirstAttemptInMillis the delay since the start of the first attempt, in milliseconds
29+
* @return the sleep time before next attempt
2930
*/
3031
long computeSleepTime(int previousAttemptNumber, long delaySinceFirstAttemptInMillis);
3132
}

0 commit comments

Comments
 (0)