4141import org .springframework .retry .policy .MapRetryContextCache ;
4242import org .springframework .retry .policy .RetryContextCache ;
4343import 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