Skip to content

Commit f6977d7

Browse files
committed
GH-137: Improve RetryTemplate.setThrowLastExceptionOnExhausted() JavaDocs
Fixes: #137 * Fix couple code smells for arrays in the `RetryTemplate`
1 parent 26697ea commit f6977d7

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/main/java/org/springframework/retry/support/RetryTemplate.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
import org.springframework.retry.policy.MapRetryContextCache;
4242
import org.springframework.retry.policy.RetryContextCache;
4343
import org.springframework.retry.policy.SimpleRetryPolicy;
44+
import org.springframework.util.Assert;
4445

4546
/**
4647
* Template class that simplifies the execution of operations with retry semantics.
@@ -120,6 +121,10 @@ public static RetryTemplate defaultInstance() {
120121
}
121122

122123
/**
124+
* Whether to re-throw last exception or wrap into {@link ExhaustedRetryException}
125+
* when all retry attempts are exhausted. Defaults to {@code false}; applied only in
126+
* case of supplied state, e.g.
127+
* {@link org.springframework.retry.interceptor.StatefulRetryOperationsInterceptor}.
123128
* @param throwLastExceptionOnExhausted the throwLastExceptionOnExhausted to set
124129
*/
125130
public void setThrowLastExceptionOnExhausted(boolean throwLastExceptionOnExhausted) {
@@ -141,7 +146,8 @@ public void setRetryContextCache(RetryContextCache retryContextCache) {
141146
* @see RetryListener
142147
*/
143148
public void setListeners(RetryListener[] listeners) {
144-
this.listeners = Arrays.asList(listeners).toArray(new RetryListener[listeners.length]);
149+
Assert.notNull(listeners, "'listeners' must not be null");
150+
this.listeners = Arrays.copyOf(listeners, listeners.length);
145151
}
146152

147153
/**
@@ -168,7 +174,7 @@ public void registerListener(RetryListener listener, int index) {
168174
else {
169175
list.add(index, listener);
170176
}
171-
this.listeners = list.toArray(new RetryListener[list.size()]);
177+
this.listeners = list.toArray(new RetryListener[0]);
172178
}
173179

174180
/**

0 commit comments

Comments
 (0)