From 214c290262b65c09da88de72ac57aa06c77afc16 Mon Sep 17 00:00:00 2001 From: Henning Poettker Date: Thu, 21 Sep 2023 22:09:04 +0200 Subject: [PATCH] Replace deprecated `RetryListenerSupport` --- .../item/SimpleRetryExceptionHandler.java | 6 ++--- .../xml/ChunkElementParserTests.java | 3 +-- .../configuration/xml/DummyRetryListener.java | 12 +--------- .../xml/SecondDummyRetryListener.java | 22 +++++++++++++++++++ .../xml/StepParserStepFactoryBeanTests.java | 8 ++++--- .../configuration/xml/StepParserTests.java | 3 +-- .../configuration/xml/TestRetryListener.java | 12 +--------- ...mentParentAttributeParserTests-context.xml | 2 +- ...StepParserParentAttributeTests-context.xml | 2 +- 9 files changed, 36 insertions(+), 34 deletions(-) create mode 100644 spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/SecondDummyRetryListener.java diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/SimpleRetryExceptionHandler.java b/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/SimpleRetryExceptionHandler.java index d02d050193..85c1d8a128 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/SimpleRetryExceptionHandler.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/SimpleRetryExceptionHandler.java @@ -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.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 @@ * @author Dave Syer * */ -public class SimpleRetryExceptionHandler extends RetryListenerSupport implements ExceptionHandler { +public class SimpleRetryExceptionHandler implements RetryListener, ExceptionHandler { /** * Attribute key, whose existence signals an exhausted retry. diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/ChunkElementParserTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/ChunkElementParserTests.java index 9e6bde2056..c973344bd6 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/ChunkElementParserTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/ChunkElementParserTests.java @@ -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; @@ -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) { diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/DummyRetryListener.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/DummyRetryListener.java index b2be498d61..a822d69b86 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/DummyRetryListener.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/DummyRetryListener.java @@ -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 boolean open(RetryContext context, RetryCallback return false; } - @Override - public void close(RetryContext context, RetryCallback callback, - Throwable throwable) { - } - - @Override - public void onError(RetryContext context, RetryCallback callback, - Throwable throwable) { - } - } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/SecondDummyRetryListener.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/SecondDummyRetryListener.java new file mode 100644 index 0000000000..ed2db73e57 --- /dev/null +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/SecondDummyRetryListener.java @@ -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 { + +} diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/StepParserStepFactoryBeanTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/StepParserStepFactoryBeanTests.java index 333d52b596..37949ce5fd 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/StepParserStepFactoryBeanTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/StepParserStepFactoryBeanTests.java @@ -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; @@ -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); @@ -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, Boolean> exceptionMap = getExceptionMap(Exception.class); fb.setSkippableExceptionClasses(exceptionMap); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/StepParserTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/StepParserTests.java index 7fe234a8a3..541e402264 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/StepParserTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/StepParserTests.java @@ -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; @@ -433,7 +432,7 @@ void testStepWithListsMerge() throws Exception { retryable.put(FatalSkippableException.class, true); retryable.put(ForceRollbackForWriteSkipException.class, true); List> streams = Arrays.asList(CompositeItemStream.class, TestReader.class); - List> retryListeners = Arrays.asList(RetryListenerSupport.class, + List> retryListeners = Arrays.asList(SecondDummyRetryListener.class, DummyRetryListener.class); List> stepListeners = Arrays.asList(DummyStepExecutionListener.class, CompositeStepExecutionListener.class); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/TestRetryListener.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/TestRetryListener.java index a07ddc6f6c..e788cbbe75 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/TestRetryListener.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/TestRetryListener.java @@ -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 @@ public class TestRetryListener extends AbstractTestComponent implements RetryListener { - @Override - public void close(RetryContext context, RetryCallback callback, - Throwable throwable) { - } - - @Override - public void onError(RetryContext context, RetryCallback callback, - Throwable throwable) { - } - @Override public boolean open(RetryContext context, RetryCallback callback) { executed = true; diff --git a/spring-batch-core/src/test/resources/org/springframework/batch/core/configuration/xml/ChunkElementParentAttributeParserTests-context.xml b/spring-batch-core/src/test/resources/org/springframework/batch/core/configuration/xml/ChunkElementParentAttributeParserTests-context.xml index 024557bb22..d816b5c75d 100644 --- a/spring-batch-core/src/test/resources/org/springframework/batch/core/configuration/xml/ChunkElementParentAttributeParserTests-context.xml +++ b/spring-batch-core/src/test/resources/org/springframework/batch/core/configuration/xml/ChunkElementParentAttributeParserTests-context.xml @@ -101,7 +101,7 @@ - + diff --git a/spring-batch-core/src/test/resources/org/springframework/batch/core/configuration/xml/StepParserParentAttributeTests-context.xml b/spring-batch-core/src/test/resources/org/springframework/batch/core/configuration/xml/StepParserParentAttributeTests-context.xml index ebab24a996..64d7da96de 100644 --- a/spring-batch-core/src/test/resources/org/springframework/batch/core/configuration/xml/StepParserParentAttributeTests-context.xml +++ b/spring-batch-core/src/test/resources/org/springframework/batch/core/configuration/xml/StepParserParentAttributeTests-context.xml @@ -162,7 +162,7 @@ - +