Skip to content

Commit

Permalink
Replace deprecated RetryListenerSupport
Browse files Browse the repository at this point in the history
  • Loading branch information
hpoettker authored and fmbenhassine committed Oct 13, 2023
1 parent b2a0d03 commit 1d097c2
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 34 deletions.
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -23,8 +23,8 @@
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;

Expand All @@ -36,7 +36,7 @@
* @author Dave Syer
*
*/
public class SimpleRetryExceptionHandler extends RetryListenerSupport implements ExceptionHandler {
public class SimpleRetryExceptionHandler implements RetryListener, ExceptionHandler {

/**
* Attribute key, whose existence signals an exhausted retry.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
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;
Expand Down Expand Up @@ -228,7 +227,7 @@ void testInheritRetryListeners() throws Exception {
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) {
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -30,14 +30,4 @@ public <T, E extends Throwable> boolean open(RetryContext context, RetryCallback
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) {
}

}
Original file line number Diff line number Diff line change
@@ -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 {

}
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
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;
Expand Down Expand Up @@ -182,7 +182,8 @@ void testFaultTolerantStepAll() {
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);
Expand Down Expand Up @@ -239,7 +240,8 @@ void testFaultTolerantStep() throws Exception {
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
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;
Expand Down Expand Up @@ -433,7 +432,7 @@ void testStepWithListsMerge() throws Exception {
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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -21,16 +21,6 @@

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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down

0 comments on commit 1d097c2

Please sign in to comment.