diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/AbstractApplicationContextFactory.java b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/AbstractApplicationContextFactory.java index 4e1b9c98d..1c41f0c38 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/AbstractApplicationContextFactory.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/AbstractApplicationContextFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2022 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. @@ -112,9 +112,7 @@ public abstract class AbstractApplicationContextFactory implements ApplicationCo public void setBeanFactoryPostProcessorClasses( Class[] beanFactoryPostProcessorClasses) { this.beanFactoryPostProcessorClasses = new ArrayList<>(); - for (int i = 0; i < beanFactoryPostProcessorClasses.length; i++) { - this.beanFactoryPostProcessorClasses.add(beanFactoryPostProcessorClasses[i]); - } + this.beanFactoryPostProcessorClasses.addAll(Arrays.asList(beanFactoryPostProcessorClasses)); } /** @@ -127,9 +125,7 @@ public abstract class AbstractApplicationContextFactory implements ApplicationCo */ public void setBeanPostProcessorExcludeClasses(Class[] beanPostProcessorExcludeClasses) { this.beanPostProcessorExcludeClasses = new ArrayList<>(); - for (int i = 0; i < beanPostProcessorExcludeClasses.length; i++) { - this.beanPostProcessorExcludeClasses.add(beanPostProcessorExcludeClasses[i]); - } + this.beanPostProcessorExcludeClasses.addAll(Arrays.asList(beanPostProcessorExcludeClasses)); } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/AutomaticJobRegistrar.java b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/AutomaticJobRegistrar.java index 75982559b..c2ed314e1 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/AutomaticJobRegistrar.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/AutomaticJobRegistrar.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2022 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. @@ -17,6 +17,7 @@ package org.springframework.batch.core.configuration.support; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collection; import org.springframework.batch.core.Job; @@ -91,9 +92,7 @@ public class AutomaticJobRegistrar implements Ordered, SmartLifecycle, Applicati * use */ public void setApplicationContextFactories(ApplicationContextFactory[] applicationContextFactories) { - for (ApplicationContextFactory applicationContextFactory : applicationContextFactories) { - this.applicationContextFactories.add(applicationContextFactory); - } + this.applicationContextFactories.addAll(Arrays.asList(applicationContextFactories)); } /** diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/step/builder/FaultTolerantStepBuilder.java b/spring-batch-core/src/main/java/org/springframework/batch/core/step/builder/FaultTolerantStepBuilder.java index 5e7947c61..186c96834 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/step/builder/FaultTolerantStepBuilder.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/step/builder/FaultTolerantStepBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2022 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. @@ -666,10 +666,7 @@ public class FaultTolerantStepBuilder extends SimpleStepBuilder { @SuppressWarnings("unchecked") private void addNonSkippableExceptionIfMissing(Class... cls) { - List> exceptions = new ArrayList<>(); - for (Class exceptionClass : nonSkippableExceptionClasses) { - exceptions.add(exceptionClass); - } + List> exceptions = new ArrayList<>(nonSkippableExceptionClasses); for (Class fatal : cls) { if (!exceptions.contains(fatal)) { exceptions.add(fatal); @@ -680,10 +677,7 @@ public class FaultTolerantStepBuilder extends SimpleStepBuilder { @SuppressWarnings("unchecked") private void addNonRetryableExceptionIfMissing(Class... cls) { - List> exceptions = new ArrayList<>(); - for (Class exceptionClass : nonRetryableExceptionClasses) { - exceptions.add(exceptionClass); - } + List> exceptions = new ArrayList<>(nonRetryableExceptionClasses); for (Class fatal : cls) { if (!exceptions.contains(fatal)) { exceptions.add(fatal); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/job/flow/support/SimpleFlowTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/job/flow/support/SimpleFlowTests.java index bfb931457..b1f7e1b92 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/job/flow/support/SimpleFlowTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/job/flow/support/SimpleFlowTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2022 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. @@ -22,6 +22,7 @@ import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collections; import java.util.List; @@ -38,6 +39,7 @@ import org.springframework.batch.core.job.flow.StateSupport; /** * @author Dave Syer * @author Michael Minella + * @author Mahmoud Ben Hassine * */ class SimpleFlowTests { @@ -208,13 +210,7 @@ class SimpleFlowTests { } protected List collect(StateTransition... states) { - List list = new ArrayList<>(); - - for (StateTransition stateTransition : states) { - list.add(stateTransition); - } - - return list; + return new ArrayList<>(Arrays.asList(states)); } /**