Replace deprecated RetryListenerSupport

This commit is contained in:
Henning Poettker
2023-09-21 22:09:04 +02:00
committed by Mahmoud Ben Hassine
parent b2a0d0343e
commit 1d097c2e31
9 changed files with 36 additions and 34 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2013 the original author or authors.
* Copyright 2006-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,8 +23,8 @@ import org.springframework.batch.repeat.support.RepeatSynchronizationManager;
import org.springframework.classify.BinaryExceptionClassifier;
import org.springframework.retry.RetryCallback;
import org.springframework.retry.RetryContext;
import org.springframework.retry.RetryListener;
import org.springframework.retry.RetryPolicy;
import org.springframework.retry.listener.RetryListenerSupport;
import java.util.Collection;
@@ -36,7 +36,7 @@ import java.util.Collection;
* @author Dave Syer
*
*/
public class SimpleRetryExceptionHandler extends RetryListenerSupport implements ExceptionHandler {
public class SimpleRetryExceptionHandler implements RetryListener, ExceptionHandler {
/**
* Attribute key, whose existence signals an exhausted retry.

View File

@@ -41,7 +41,6 @@ import org.springframework.dao.ConcurrencyFailureException;
import org.springframework.dao.DeadlockLoserDataAccessException;
import org.springframework.dao.PessimisticLockingFailureException;
import org.springframework.retry.RetryListener;
import org.springframework.retry.listener.RetryListenerSupport;
import org.springframework.retry.policy.SimpleRetryPolicy;
import org.springframework.test.util.ReflectionTestUtils;
import org.springframework.util.StringUtils;
@@ -228,7 +227,7 @@ class ChunkElementParserTests {
boolean g = false;
boolean h = false;
for (RetryListener o : retryListeners) {
if (o instanceof RetryListenerSupport) {
if (o instanceof SecondDummyRetryListener) {
g = true;
}
else if (o instanceof DummyRetryListener) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2009-2012 the original author or authors.
* Copyright 2009-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -30,14 +30,4 @@ public class DummyRetryListener implements RetryListener {
return false;
}
@Override
public <T, E extends Throwable> void close(RetryContext context, RetryCallback<T, E> callback,
Throwable throwable) {
}
@Override
public <T, E extends Throwable> void onError(RetryContext context, RetryCallback<T, E> callback,
Throwable throwable) {
}
}

View File

@@ -0,0 +1,22 @@
/*
* Copyright 2023-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.batch.core.configuration.xml;
import org.springframework.retry.RetryListener;
public class SecondDummyRetryListener implements RetryListener {
}

View File

@@ -43,7 +43,7 @@ import org.springframework.batch.repeat.support.TaskExecutorRepeatTemplate;
import org.springframework.batch.support.transaction.ResourcelessTransactionManager;
import org.springframework.core.task.SimpleAsyncTaskExecutor;
import org.springframework.core.task.SyncTaskExecutor;
import org.springframework.retry.listener.RetryListenerSupport;
import org.springframework.retry.RetryListener;
import org.springframework.test.util.ReflectionTestUtils;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
@@ -182,7 +182,8 @@ class StepParserStepFactoryBeanTests {
fb.setIsReaderTransactionalQueue(true);
fb.setRetryLimit(5);
fb.setSkipLimit(100);
fb.setRetryListeners(new RetryListenerSupport());
fb.setRetryListeners(new RetryListener() {
});
fb.setSkippableExceptionClasses(new HashMap<>());
fb.setRetryableExceptionClasses(new HashMap<>());
fb.setHasChunkElement(true);
@@ -239,7 +240,8 @@ class StepParserStepFactoryBeanTests {
fb.setRetryLimit(5);
fb.setSkipLimit(100);
fb.setThrottleLimit(10);
fb.setRetryListeners(new RetryListenerSupport());
fb.setRetryListeners(new RetryListener() {
});
@SuppressWarnings("unchecked")
Map<Class<? extends Throwable>, Boolean> exceptionMap = getExceptionMap(Exception.class);
fb.setSkippableExceptionClasses(exceptionMap);

View File

@@ -53,7 +53,6 @@ import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.dao.DeadlockLoserDataAccessException;
import org.springframework.jdbc.support.JdbcTransactionManager;
import org.springframework.retry.RetryListener;
import org.springframework.retry.listener.RetryListenerSupport;
import org.springframework.test.util.ReflectionTestUtils;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.TransactionDefinition;
@@ -433,7 +432,7 @@ public class StepParserTests {
retryable.put(FatalSkippableException.class, true);
retryable.put(ForceRollbackForWriteSkipException.class, true);
List<Class<? extends ItemStream>> streams = Arrays.asList(CompositeItemStream.class, TestReader.class);
List<Class<? extends RetryListener>> retryListeners = Arrays.asList(RetryListenerSupport.class,
List<Class<? extends RetryListener>> retryListeners = Arrays.asList(SecondDummyRetryListener.class,
DummyRetryListener.class);
List<Class<? extends StepExecutionListener>> stepListeners = Arrays.asList(DummyStepExecutionListener.class,
CompositeStepExecutionListener.class);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2008-2012 the original author or authors.
* Copyright 2008-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,16 +21,6 @@ import org.springframework.retry.RetryListener;
public class TestRetryListener extends AbstractTestComponent implements RetryListener {
@Override
public <T, E extends Throwable> void close(RetryContext context, RetryCallback<T, E> callback,
Throwable throwable) {
}
@Override
public <T, E extends Throwable> void onError(RetryContext context, RetryCallback<T, E> callback,
Throwable throwable) {
}
@Override
public <T, E extends Throwable> boolean open(RetryContext context, RetryCallback<T, E> callback) {
executed = true;

View File

@@ -101,7 +101,7 @@
</streams>
<retry-listeners>
<listener>
<beans:bean class="org.springframework.retry.listener.RetryListenerSupport"/>
<beans:bean class="org.springframework.batch.core.configuration.xml.SecondDummyRetryListener"/>
</listener>
</retry-listeners>
</chunk>

View File

@@ -162,7 +162,7 @@
</streams>
<retry-listeners>
<listener>
<beans:bean class="org.springframework.retry.listener.RetryListenerSupport"/>
<beans:bean class="org.springframework.batch.core.configuration.xml.SecondDummyRetryListener"/>
</listener>
</retry-listeners>
</chunk>