diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/job/DefaultJobParametersValidator.java b/spring-batch-core/src/main/java/org/springframework/batch/core/job/DefaultJobParametersValidator.java index 6a8ff8ffa..259a2d472 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/job/DefaultJobParametersValidator.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/job/DefaultJobParametersValidator.java @@ -112,7 +112,7 @@ public class DefaultJobParametersValidator implements JobParametersValidator, In * * @see #setOptionalKeys(String[]) */ - public void setRequiredKeys(String[] requiredKeys) { + public final void setRequiredKeys(String[] requiredKeys) { this.requiredKeys = new HashSet(Arrays.asList(requiredKeys)); } @@ -126,7 +126,7 @@ public class DefaultJobParametersValidator implements JobParametersValidator, In * * @see #setRequiredKeys(String[]) */ - public void setOptionalKeys(String[] optionalKeys) { + public final void setOptionalKeys(String[] optionalKeys) { this.optionalKeys = new HashSet(Arrays.asList(optionalKeys)); } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/job/flow/support/StateTransition.java b/spring-batch-core/src/main/java/org/springframework/batch/core/job/flow/support/StateTransition.java index 1f97a7b8b..35c136166 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/job/flow/support/StateTransition.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/job/flow/support/StateTransition.java @@ -30,7 +30,7 @@ import org.springframework.util.StringUtils; * @author Dave Syer * @since 2.0 */ -public class StateTransition implements Comparable { +public final class StateTransition implements Comparable { private final State state; diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/launch/support/SimpleJobLauncher.java b/spring-batch-core/src/main/java/org/springframework/batch/core/launch/support/SimpleJobLauncher.java index c83a2205f..44fddf184 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/launch/support/SimpleJobLauncher.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/launch/support/SimpleJobLauncher.java @@ -133,7 +133,10 @@ public class SimpleJobLauncher implements JobLauncher, InitializingBean { if (t instanceof RuntimeException) { throw (RuntimeException) t; } - throw new RuntimeException(t); + else if (t instanceof Error) { + throw (Error) t; + } + throw new IllegalStateException(t); } }); } diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/classify/ClassifierAdapter.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/classify/ClassifierAdapter.java index 6077e30a8..6eba544a3 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/classify/ClassifierAdapter.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/classify/ClassifierAdapter.java @@ -76,7 +76,7 @@ public class ClassifierAdapter implements Classifier { * * @param delegate an object with an annotated method */ - public void setDelegate(Object delegate) { + public final void setDelegate(Object delegate) { classifier = null; invoker = MethodInvokerUtils.getMethodInvokerByAnnotation( org.springframework.batch.support.annotation.Classifier.class, delegate); diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/classify/SubclassClassifier.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/classify/SubclassClassifier.java index 153498c11..b19c04aae 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/classify/SubclassClassifier.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/classify/SubclassClassifier.java @@ -63,7 +63,7 @@ public class SubclassClassifier implements Classifier { */ public SubclassClassifier(Map, C> typeMap, C defaultValue) { super(); - setTypeMap(typeMap); + this.classified = new HashMap, C>(typeMap); this.defaultValue = defaultValue; } diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/adapter/AbstractMethodInvokingDelegator.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/adapter/AbstractMethodInvokingDelegator.java index c3de06d50..7382aeaac 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/adapter/AbstractMethodInvokingDelegator.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/adapter/AbstractMethodInvokingDelegator.java @@ -207,7 +207,7 @@ public abstract class AbstractMethodInvokingDelegator implements Initializing * is assumed correct values will be supplied at runtime. */ public void setArguments(Object[] arguments) { - this.arguments = arguments; + this.arguments = Arrays.asList(arguments).toArray(); } /** diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/adapter/PropertyExtractingDelegatingItemWriter.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/adapter/PropertyExtractingDelegatingItemWriter.java index 2c547bbf4..ce094a44b 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/adapter/PropertyExtractingDelegatingItemWriter.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/adapter/PropertyExtractingDelegatingItemWriter.java @@ -16,6 +16,7 @@ package org.springframework.batch.item.adapter; +import java.util.Arrays; import java.util.List; import org.springframework.batch.item.ItemWriter; @@ -68,7 +69,8 @@ public class PropertyExtractingDelegatingItemWriter extends AbstractMethodInv * are supported, e.g. address.city */ public void setFieldsUsedAsTargetMethodArguments(String[] fieldsUsedAsMethodArguments) { - this.fieldsUsedAsTargetMethodArguments = fieldsUsedAsMethodArguments; + this.fieldsUsedAsTargetMethodArguments = Arrays.asList(fieldsUsedAsMethodArguments).toArray( + new String[fieldsUsedAsMethodArguments.length]); } } diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/MultiResourceItemReader.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/MultiResourceItemReader.java index b653c62e5..1320b491e 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/MultiResourceItemReader.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/MultiResourceItemReader.java @@ -47,7 +47,7 @@ import org.springframework.util.ClassUtils; public class MultiResourceItemReader implements ItemReader, ItemStream { private static final Log logger = LogFactory.getLog(MultiResourceItemReader.class); - + private static final String RESOURCE_KEY = "resourceIndex"; private final ExecutionContextUserSupport executionContextUserSupport = new ExecutionContextUserSupport(); @@ -57,7 +57,7 @@ public class MultiResourceItemReader implements ItemReader, ItemStream { private Resource[] resources; private boolean saveState = true; - + private int currentResource = -1; // signals there are no resources to read -> just return null on first read @@ -86,10 +86,10 @@ public class MultiResourceItemReader implements ItemReader, ItemStream { if (noInput) { return null; } - - //If there is no resource, then this is the first item, set the current - //resource to 0 and open the first delegate. - if(currentResource == -1){ + + // If there is no resource, then this is the first item, set the current + // resource to 0 and open the first delegate. + if (currentResource == -1) { currentResource = 0; delegate.setResource(resources[currentResource]); delegate.open(new ExecutionContext()); @@ -159,7 +159,7 @@ public class MultiResourceItemReader implements ItemReader, ItemStream { delegate.setResource(resources[currentResource]); delegate.open(executionContext); } - else{ + else { currentResource = -1; } } @@ -194,7 +194,7 @@ public class MultiResourceItemReader implements ItemReader, ItemStream { /** * @param comparator used to order the injected resources, by default - * compares {@link Resource#getFilename()} values. + * compares {@link Resource#getFilename()} values. */ public void setComparator(Comparator comparator) { this.comparator = comparator; @@ -204,7 +204,7 @@ public class MultiResourceItemReader implements ItemReader, ItemStream { * @param resources input resources */ public void setResources(Resource[] resources) { - this.resources = resources; + this.resources = Arrays.asList(resources).toArray(new Resource[resources.length]); } public Resource getCurrentResource() { diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/ResourcesItemReader.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/ResourcesItemReader.java index 19589cf01..5d1140c2d 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/ResourcesItemReader.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/ResourcesItemReader.java @@ -1,5 +1,6 @@ package org.springframework.batch.item.file; +import java.util.Arrays; import java.util.concurrent.atomic.AtomicInteger; import org.springframework.batch.item.ExecutionContext; @@ -48,7 +49,7 @@ public class ResourcesItemReader extends ExecutionContextUserSupport implements * @param resources the resources */ public void setResources(Resource[] resources) { - this.resources = resources; + this.resources = Arrays.asList(resources).toArray(new Resource[resources.length]); } /** diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/transform/AbstractLineTokenizer.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/transform/AbstractLineTokenizer.java index dae65e9f1..793320c86 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/transform/AbstractLineTokenizer.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/transform/AbstractLineTokenizer.java @@ -17,6 +17,7 @@ package org.springframework.batch.item.file.transform; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; /** @@ -78,7 +79,7 @@ public abstract class AbstractLineTokenizer implements LineTokenizer { * @param names */ public void setNames(String[] names) { - this.names = names; + this.names = Arrays.asList(names).toArray(new String[names.length]); } /** diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/transform/BeanWrapperFieldExtractor.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/transform/BeanWrapperFieldExtractor.java index c584a49cf..19a4ade8a 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/transform/BeanWrapperFieldExtractor.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/transform/BeanWrapperFieldExtractor.java @@ -17,6 +17,7 @@ package org.springframework.batch.item.file.transform; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import org.springframework.beans.BeanWrapper; @@ -40,7 +41,7 @@ public class BeanWrapperFieldExtractor implements FieldExtractor, Initiali * @param names field names to be extracted by the {@link #extract(Object)} method. */ public void setNames(String[] names) { - this.names = names; + this.names = Arrays.asList(names).toArray(new String[names.length]); } /** diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/transform/DefaultFieldSet.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/transform/DefaultFieldSet.java index baa8ccce6..45ee0883e 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/transform/DefaultFieldSet.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/transform/DefaultFieldSet.java @@ -64,7 +64,7 @@ public class DefaultFieldSet implements FieldSet { * US locale will be used ('.' as decimal place). * @param numberFormat the {@link NumberFormat} to use for number parsing */ - public void setNumberFormat(NumberFormat numberFormat) { + public final void setNumberFormat(NumberFormat numberFormat) { this.numberFormat = numberFormat; if (numberFormat instanceof DecimalFormat) { grouping = ""+((DecimalFormat)numberFormat).getDecimalFormatSymbols().getGroupingSeparator(); diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/transform/DelimitedLineTokenizer.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/transform/DelimitedLineTokenizer.java index 5eb06fe13..397a34f2d 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/transform/DelimitedLineTokenizer.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/transform/DelimitedLineTokenizer.java @@ -96,7 +96,7 @@ public class DelimitedLineTokenizer extends AbstractLineTokenizer { * * @see #DEFAULT_QUOTE_CHARACTER */ - public void setQuoteCharacter(char quoteCharacter) { + public final void setQuoteCharacter(char quoteCharacter) { this.quoteCharacter = quoteCharacter; this.quoteString = "" + quoteCharacter; } @@ -167,9 +167,9 @@ public class DelimitedLineTokenizer extends AbstractLineTokenizer { if (endLength == 0) { endLength = 1; } - string = value.substring(1, endLength); + value = value.substring(1, endLength); } - return string; + return value; } /** diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/transform/FixedLengthTokenizer.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/transform/FixedLengthTokenizer.java index 1a85073f4..8124d5e4f 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/transform/FixedLengthTokenizer.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/transform/FixedLengthTokenizer.java @@ -17,6 +17,7 @@ package org.springframework.batch.item.file.transform; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; /** @@ -49,7 +50,7 @@ public class FixedLengthTokenizer extends AbstractLineTokenizer { * @param ranges the column ranges expected in the input */ public void setColumns(Range[] ranges) { - this.ranges = ranges; + this.ranges = Arrays.asList(ranges).toArray(new Range[ranges.length]); calculateMaxRange(ranges); } diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/util/FileUtils.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/util/FileUtils.java index f4c8f289a..8d8de3f64 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/util/FileUtils.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/util/FileUtils.java @@ -27,7 +27,7 @@ import org.springframework.util.Assert; * * @author Peter Zozom */ -public class FileUtils { +public final class FileUtils { // forbids instantiation private FileUtils() { diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/repeat/context/SynchronizedAttributeAccessor.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/repeat/context/SynchronizedAttributeAccessor.java index 1e345fa1e..a65c1f43f 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/repeat/context/SynchronizedAttributeAccessor.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/repeat/context/SynchronizedAttributeAccessor.java @@ -148,7 +148,7 @@ public class SynchronizedAttributeAccessor implements AttributeAccessor { String[] names = attributeNames(); for (int i = 0; i < names.length; i++) { String name = names[i]; - buffer.append(names[i] + "=" + getAttribute(name)); + buffer.append(names[i]).append("=").append(getAttribute(name)); if (i < names.length - 1) { buffer.append(", "); } diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/repeat/exception/CompositeExceptionHandler.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/repeat/exception/CompositeExceptionHandler.java index 3c76ebf95..697f3c920 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/repeat/exception/CompositeExceptionHandler.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/repeat/exception/CompositeExceptionHandler.java @@ -16,6 +16,7 @@ package org.springframework.batch.repeat.exception; +import java.util.Arrays; import org.springframework.batch.repeat.RepeatContext; @@ -30,7 +31,7 @@ public class CompositeExceptionHandler implements ExceptionHandler { private ExceptionHandler[] handlers = new ExceptionHandler[0]; public void setHandlers(ExceptionHandler[] handlers) { - this.handlers = handlers; + this.handlers = Arrays.asList(handlers).toArray(new ExceptionHandler[handlers.length]); } /** diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/repeat/policy/CompositeCompletionPolicy.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/repeat/policy/CompositeCompletionPolicy.java index 0f43d2e7a..87763a7a2 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/repeat/policy/CompositeCompletionPolicy.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/repeat/policy/CompositeCompletionPolicy.java @@ -17,11 +17,12 @@ package org.springframework.batch.repeat.policy; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import org.springframework.batch.repeat.CompletionPolicy; -import org.springframework.batch.repeat.RepeatStatus; import org.springframework.batch.repeat.RepeatContext; +import org.springframework.batch.repeat.RepeatStatus; import org.springframework.batch.repeat.context.RepeatContextSupport; /** @@ -41,7 +42,7 @@ public class CompositeCompletionPolicy implements CompletionPolicy { * @param policies */ public void setPolicies(CompletionPolicy[] policies) { - this.policies = policies; + this.policies = Arrays.asList(policies).toArray(new CompletionPolicy[policies.length]); } /** diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/repeat/support/RepeatSynchronizationManager.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/repeat/support/RepeatSynchronizationManager.java index 0ac356d74..ab4ac1f59 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/repeat/support/RepeatSynchronizationManager.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/repeat/support/RepeatSynchronizationManager.java @@ -33,7 +33,7 @@ import org.springframework.batch.repeat.RepeatOperations; * @author Dave Syer * */ -public class RepeatSynchronizationManager { +public final class RepeatSynchronizationManager { private static final ThreadLocal contextHolder = new ThreadLocal(); diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/repeat/support/RepeatTemplate.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/repeat/support/RepeatTemplate.java index 299d6df85..b4f4e38b7 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/repeat/support/RepeatTemplate.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/repeat/support/RepeatTemplate.java @@ -24,12 +24,12 @@ import java.util.List; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.springframework.batch.repeat.CompletionPolicy; -import org.springframework.batch.repeat.RepeatStatus; import org.springframework.batch.repeat.RepeatCallback; import org.springframework.batch.repeat.RepeatContext; import org.springframework.batch.repeat.RepeatException; import org.springframework.batch.repeat.RepeatListener; import org.springframework.batch.repeat.RepeatOperations; +import org.springframework.batch.repeat.RepeatStatus; import org.springframework.batch.repeat.exception.DefaultExceptionHandler; import org.springframework.batch.repeat.exception.ExceptionHandler; import org.springframework.batch.repeat.policy.DefaultResultCompletionPolicy; @@ -79,7 +79,7 @@ public class RepeatTemplate implements RepeatOperations { * @param listeners */ public void setListeners(RepeatListener[] listeners) { - this.listeners = listeners; + this.listeners = Arrays.asList(listeners).toArray(new RepeatListener[listeners.length]); } /** diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/retry/interceptor/StatefulRetryOperationsInterceptor.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/retry/interceptor/StatefulRetryOperationsInterceptor.java index df712ade5..b446d0b95 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/retry/interceptor/StatefulRetryOperationsInterceptor.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/retry/interceptor/StatefulRetryOperationsInterceptor.java @@ -16,6 +16,8 @@ package org.springframework.batch.retry.interceptor; +import java.util.Arrays; + import org.aopalliance.intercept.MethodInterceptor; import org.aopalliance.intercept.MethodInvocation; import org.apache.commons.logging.Log; @@ -37,8 +39,8 @@ import org.springframework.util.ObjectUtils; * a method on a service if it fails. The argument to the service method is * treated as an item to be remembered in case the call fails. So the retry * operation is stateful, and the item that failed is tracked by its unique key - * (via {@link MethodArgumentsKeyGenerator}) until the retry is exhausted, at which point - * the {@link MethodInvocationRecoverer} is called.
+ * (via {@link MethodArgumentsKeyGenerator}) until the retry is exhausted, at + * which point the {@link MethodInvocationRecoverer} is called.
* * The main use case for this is where the service is transactional, via a * transaction interceptor on the interceptor chain. In this case the retry (and @@ -78,10 +80,10 @@ public class StatefulRetryOperationsInterceptor implements MethodInterceptor { } /** - * Public setter for the {@link MethodInvocationRecoverer} to use if the retry is - * exhausted. The recoverer should be able to return an object of the same - * type as the target object because its return value will be used to return - * to the caller in the case of a recovery.
+ * Public setter for the {@link MethodInvocationRecoverer} to use if the + * retry is exhausted. The recoverer should be able to return an object of + * the same type as the target object because its return value will be used + * to return to the caller in the case of a recovery.
* * If no recoverer is set then an exhausted retry will result in an * {@link ExhaustedRetryException}. @@ -97,10 +99,11 @@ public class StatefulRetryOperationsInterceptor implements MethodInterceptor { } /** - * Public setter for the {@link NewMethodArgumentsIdentifier}. Only set this if the - * arguments to the intercepted method can be inspected to find out if they - * have never been processed before. - * @param newMethodArgumentsIdentifier the {@link NewMethodArgumentsIdentifier} to set + * Public setter for the {@link NewMethodArgumentsIdentifier}. Only set this + * if the arguments to the intercepted method can be inspected to find out + * if they have never been processed before. + * @param newMethodArgumentsIdentifier the + * {@link NewMethodArgumentsIdentifier} to set */ public void setNewItemIdentifier(NewMethodArgumentsIdentifier newMethodArgumentsIdentifier) { this.newMethodArgumentsIdentifier = newMethodArgumentsIdentifier; @@ -110,10 +113,11 @@ public class StatefulRetryOperationsInterceptor implements MethodInterceptor { * Wrap the method invocation in a stateful retry with the policy and other * helpers provided. If there is a failure the exception will generally be * re-thrown. The only time it is not re-thrown is when retry is exhausted - * and the recovery path is taken (though the {@link MethodInvocationRecoverer} provided - * if there is one). In that case the value returned from the method - * invocation will be the value returned by the recoverer (so the return - * type for that should be the same as the intercepted method). + * and the recovery path is taken (though the + * {@link MethodInvocationRecoverer} provided if there is one). In that case + * the value returned from the method invocation will be the value returned + * by the recoverer (so the return type for that should be the same as the + * intercepted method). * * @see org.aopalliance.intercept.MethodInterceptor#invoke(org.aopalliance.intercept.MethodInvocation) * @see MethodInvocationRecoverer#recover(Object[], Throwable) @@ -135,9 +139,11 @@ public class StatefulRetryOperationsInterceptor implements MethodInterceptor { } final Object item = arg; - RetryState retryState = new DefaultRetryState(keyGenerator != null ? keyGenerator.getKey(args) : item, newMethodArgumentsIdentifier != null ? newMethodArgumentsIdentifier.isNew(args) : false ); + RetryState retryState = new DefaultRetryState(keyGenerator != null ? keyGenerator.getKey(args) : item, + newMethodArgumentsIdentifier != null ? newMethodArgumentsIdentifier.isNew(args) : false); - Object result = retryOperations.execute(new MethodInvocationRetryCallback(invocation), new ItemRecovererCallback(args, recoverer), retryState); + Object result = retryOperations.execute(new MethodInvocationRetryCallback(invocation), + new ItemRecovererCallback(args, recoverer), retryState); logger.debug("Exiting proxied method in stateful retry with result: (" + result + ")"); @@ -192,7 +198,7 @@ public class StatefulRetryOperationsInterceptor implements MethodInterceptor { * @param args the item that failed. */ private ItemRecovererCallback(Object[] args, MethodInvocationRecoverer recoverer) { - this.args = args; + this.args = Arrays.asList(args).toArray(); this.recoverer = recoverer; } diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/retry/policy/CompositeRetryPolicy.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/retry/policy/CompositeRetryPolicy.java index 77ae573d8..a379b38fb 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/retry/policy/CompositeRetryPolicy.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/retry/policy/CompositeRetryPolicy.java @@ -17,6 +17,7 @@ package org.springframework.batch.retry.policy; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import org.springframework.batch.retry.RetryContext; @@ -40,7 +41,7 @@ public class CompositeRetryPolicy implements RetryPolicy { * @param policies */ public void setPolicies(RetryPolicy[] policies) { - this.policies = policies; + this.policies = Arrays.asList(policies).toArray(new RetryPolicy[policies.length]); } /** @@ -77,12 +78,12 @@ public class CompositeRetryPolicy implements RetryPolicy { policies[i].close(contexts[i]); } catch (RuntimeException e) { - if (exception==null) { + if (exception == null) { exception = e; } } } - if (exception!=null) { + if (exception != null) { throw exception; } } diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/retry/support/RetrySynchronizationManager.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/retry/support/RetrySynchronizationManager.java index 268801959..30fa5448a 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/retry/support/RetrySynchronizationManager.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/retry/support/RetrySynchronizationManager.java @@ -34,7 +34,7 @@ import org.springframework.batch.retry.RetryOperations; * @author Dave Syer * */ -public class RetrySynchronizationManager { +public final class RetrySynchronizationManager { private RetrySynchronizationManager() {} diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/retry/support/RetryTemplate.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/retry/support/RetryTemplate.java index 2d5fc1714..d8aebb3bd 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/retry/support/RetryTemplate.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/retry/support/RetryTemplate.java @@ -100,7 +100,7 @@ public class RetryTemplate implements RetryOperations { * @see RetryListener */ public void setListeners(RetryListener[] listeners) { - this.listeners = listeners; + this.listeners = Arrays.asList(listeners).toArray(new RetryListener[listeners.length]); } /** diff --git a/spring-batch-test/src/main/java/org/springframework/batch/test/JobRepositoryTestUtils.java b/spring-batch-test/src/main/java/org/springframework/batch/test/JobRepositoryTestUtils.java index 9bf9278ce..6320b8548 100644 --- a/spring-batch-test/src/main/java/org/springframework/batch/test/JobRepositoryTestUtils.java +++ b/spring-batch-test/src/main/java/org/springframework/batch/test/JobRepositoryTestUtils.java @@ -93,7 +93,7 @@ public class JobRepositoryTestUtils extends AbstractJdbcBatchMetadataDao impleme setDataSource(dataSource); } - public void setDataSource(DataSource dataSource) { + public final void setDataSource(DataSource dataSource) { jdbcTemplate = new SimpleJdbcTemplate(dataSource); } diff --git a/spring-batch-test/src/main/java/org/springframework/batch/test/StepRunner.java b/spring-batch-test/src/main/java/org/springframework/batch/test/StepRunner.java index f4364e60b..b8a5cbca8 100755 --- a/spring-batch-test/src/main/java/org/springframework/batch/test/StepRunner.java +++ b/spring-batch-test/src/main/java/org/springframework/batch/test/StepRunner.java @@ -31,6 +31,7 @@ import org.springframework.batch.core.JobParameter; import org.springframework.batch.core.JobParameters; import org.springframework.batch.core.JobParametersInvalidException; import org.springframework.batch.core.Step; +import org.springframework.batch.core.UnexpectedJobExecutionException; import org.springframework.batch.core.job.SimpleJob; import org.springframework.batch.core.launch.JobLauncher; import org.springframework.batch.core.listener.JobExecutionListenerSupport; @@ -168,16 +169,16 @@ public class StepRunner { return this.launcher.run(job, jobParameters); } catch (JobExecutionAlreadyRunningException e) { - throw new RuntimeException(e); + throw new UnexpectedJobExecutionException("Step runner encountered exception.", e); } catch (JobRestartException e) { - throw new RuntimeException(e); + throw new UnexpectedJobExecutionException("Step runner encountered exception.", e); } catch (JobInstanceAlreadyCompleteException e) { - throw new RuntimeException(e); + throw new UnexpectedJobExecutionException("Step runner encountered exception.", e); } catch (JobParametersInvalidException e) { - throw new RuntimeException(e); + throw new UnexpectedJobExecutionException("Step runner encountered exception.", e); } }