Skip to content

Commit 1d097c2

Browse files
hpoettkerfmbenhassine
authored andcommitted
Replace deprecated RetryListenerSupport
1 parent b2a0d03 commit 1d097c2

File tree

9 files changed

+36
-34
lines changed

9 files changed

+36
-34
lines changed

spring-batch-core/src/main/java/org/springframework/batch/core/step/item/SimpleRetryExceptionHandler.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2006-2013 the original author or authors.
2+
* Copyright 2006-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -23,8 +23,8 @@
2323
import org.springframework.classify.BinaryExceptionClassifier;
2424
import org.springframework.retry.RetryCallback;
2525
import org.springframework.retry.RetryContext;
26+
import org.springframework.retry.RetryListener;
2627
import org.springframework.retry.RetryPolicy;
27-
import org.springframework.retry.listener.RetryListenerSupport;
2828

2929
import java.util.Collection;
3030

@@ -36,7 +36,7 @@
3636
* @author Dave Syer
3737
*
3838
*/
39-
public class SimpleRetryExceptionHandler extends RetryListenerSupport implements ExceptionHandler {
39+
public class SimpleRetryExceptionHandler implements RetryListener, ExceptionHandler {
4040

4141
/**
4242
* Attribute key, whose existence signals an exhausted retry.

spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/ChunkElementParserTests.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
import org.springframework.dao.DeadlockLoserDataAccessException;
4242
import org.springframework.dao.PessimisticLockingFailureException;
4343
import org.springframework.retry.RetryListener;
44-
import org.springframework.retry.listener.RetryListenerSupport;
4544
import org.springframework.retry.policy.SimpleRetryPolicy;
4645
import org.springframework.test.util.ReflectionTestUtils;
4746
import org.springframework.util.StringUtils;
@@ -228,7 +227,7 @@ void testInheritRetryListeners() throws Exception {
228227
boolean g = false;
229228
boolean h = false;
230229
for (RetryListener o : retryListeners) {
231-
if (o instanceof RetryListenerSupport) {
230+
if (o instanceof SecondDummyRetryListener) {
232231
g = true;
233232
}
234233
else if (o instanceof DummyRetryListener) {

spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/DummyRetryListener.java

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2009-2012 the original author or authors.
2+
* Copyright 2009-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -30,14 +30,4 @@ public <T, E extends Throwable> boolean open(RetryContext context, RetryCallback
3030
return false;
3131
}
3232

33-
@Override
34-
public <T, E extends Throwable> void close(RetryContext context, RetryCallback<T, E> callback,
35-
Throwable throwable) {
36-
}
37-
38-
@Override
39-
public <T, E extends Throwable> void onError(RetryContext context, RetryCallback<T, E> callback,
40-
Throwable throwable) {
41-
}
42-
4333
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*
2+
* Copyright 2023-2023 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.springframework.batch.core.configuration.xml;
17+
18+
import org.springframework.retry.RetryListener;
19+
20+
public class SecondDummyRetryListener implements RetryListener {
21+
22+
}

spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/StepParserStepFactoryBeanTests.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
import org.springframework.batch.support.transaction.ResourcelessTransactionManager;
4444
import org.springframework.core.task.SimpleAsyncTaskExecutor;
4545
import org.springframework.core.task.SyncTaskExecutor;
46-
import org.springframework.retry.listener.RetryListenerSupport;
46+
import org.springframework.retry.RetryListener;
4747
import org.springframework.test.util.ReflectionTestUtils;
4848
import org.springframework.transaction.annotation.Isolation;
4949
import org.springframework.transaction.annotation.Propagation;
@@ -182,7 +182,8 @@ void testFaultTolerantStepAll() {
182182
fb.setIsReaderTransactionalQueue(true);
183183
fb.setRetryLimit(5);
184184
fb.setSkipLimit(100);
185-
fb.setRetryListeners(new RetryListenerSupport());
185+
fb.setRetryListeners(new RetryListener() {
186+
});
186187
fb.setSkippableExceptionClasses(new HashMap<>());
187188
fb.setRetryableExceptionClasses(new HashMap<>());
188189
fb.setHasChunkElement(true);
@@ -239,7 +240,8 @@ void testFaultTolerantStep() throws Exception {
239240
fb.setRetryLimit(5);
240241
fb.setSkipLimit(100);
241242
fb.setThrottleLimit(10);
242-
fb.setRetryListeners(new RetryListenerSupport());
243+
fb.setRetryListeners(new RetryListener() {
244+
});
243245
@SuppressWarnings("unchecked")
244246
Map<Class<? extends Throwable>, Boolean> exceptionMap = getExceptionMap(Exception.class);
245247
fb.setSkippableExceptionClasses(exceptionMap);

spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/StepParserTests.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@
5353
import org.springframework.dao.DeadlockLoserDataAccessException;
5454
import org.springframework.jdbc.support.JdbcTransactionManager;
5555
import org.springframework.retry.RetryListener;
56-
import org.springframework.retry.listener.RetryListenerSupport;
5756
import org.springframework.test.util.ReflectionTestUtils;
5857
import org.springframework.transaction.PlatformTransactionManager;
5958
import org.springframework.transaction.TransactionDefinition;
@@ -433,7 +432,7 @@ void testStepWithListsMerge() throws Exception {
433432
retryable.put(FatalSkippableException.class, true);
434433
retryable.put(ForceRollbackForWriteSkipException.class, true);
435434
List<Class<? extends ItemStream>> streams = Arrays.asList(CompositeItemStream.class, TestReader.class);
436-
List<Class<? extends RetryListener>> retryListeners = Arrays.asList(RetryListenerSupport.class,
435+
List<Class<? extends RetryListener>> retryListeners = Arrays.asList(SecondDummyRetryListener.class,
437436
DummyRetryListener.class);
438437
List<Class<? extends StepExecutionListener>> stepListeners = Arrays.asList(DummyStepExecutionListener.class,
439438
CompositeStepExecutionListener.class);

spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/TestRetryListener.java

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2008-2012 the original author or authors.
2+
* Copyright 2008-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -21,16 +21,6 @@
2121

2222
public class TestRetryListener extends AbstractTestComponent implements RetryListener {
2323

24-
@Override
25-
public <T, E extends Throwable> void close(RetryContext context, RetryCallback<T, E> callback,
26-
Throwable throwable) {
27-
}
28-
29-
@Override
30-
public <T, E extends Throwable> void onError(RetryContext context, RetryCallback<T, E> callback,
31-
Throwable throwable) {
32-
}
33-
3424
@Override
3525
public <T, E extends Throwable> boolean open(RetryContext context, RetryCallback<T, E> callback) {
3626
executed = true;

spring-batch-core/src/test/resources/org/springframework/batch/core/configuration/xml/ChunkElementParentAttributeParserTests-context.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@
101101
</streams>
102102
<retry-listeners>
103103
<listener>
104-
<beans:bean class="org.springframework.retry.listener.RetryListenerSupport"/>
104+
<beans:bean class="org.springframework.batch.core.configuration.xml.SecondDummyRetryListener"/>
105105
</listener>
106106
</retry-listeners>
107107
</chunk>

spring-batch-core/src/test/resources/org/springframework/batch/core/configuration/xml/StepParserParentAttributeTests-context.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@
162162
</streams>
163163
<retry-listeners>
164164
<listener>
165-
<beans:bean class="org.springframework.retry.listener.RetryListenerSupport"/>
165+
<beans:bean class="org.springframework.batch.core.configuration.xml.SecondDummyRetryListener"/>
166166
</listener>
167167
</retry-listeners>
168168
</chunk>

0 commit comments

Comments
 (0)