Mark fields as final where appropriate

This commit is contained in:
Mahmoud Ben Hassine
2023-07-04 21:45:20 +02:00
parent 241e37e672
commit 0a1cdb095f
166 changed files with 411 additions and 365 deletions

View File

@@ -36,11 +36,11 @@ import org.springframework.util.Assert;
*/
public class JobParameter<T> implements Serializable {
private T value;
private final T value;
private Class<T> type;
private final Class<T> type;
private boolean identifying;
private final boolean identifying;
/**
* Create a new {@link JobParameter}.

View File

@@ -44,7 +44,7 @@ public class StepContribution implements Serializable {
private ExitStatus exitStatus = ExitStatus.EXECUTING;
private volatile StepExecution stepExecution;
private final StepExecution stepExecution;
/**
* @param execution {@link StepExecution} the stepExecution used to initialize

View File

@@ -52,7 +52,7 @@ public abstract class AbstractApplicationContextFactory implements ApplicationCo
private static final Log logger = LogFactory.getLog(AbstractApplicationContextFactory.class);
private Object[] resources;
private final Object[] resources;
private ConfigurableApplicationContext parent;

View File

@@ -45,7 +45,7 @@ import org.springframework.util.Assert;
*/
public class AutomaticJobRegistrar implements Ordered, SmartLifecycle, ApplicationContextAware, InitializingBean {
private Collection<ApplicationContextFactory> applicationContextFactories = new ArrayList<>();
private final Collection<ApplicationContextFactory> applicationContextFactories = new ArrayList<>();
private JobLoader jobLoader;
@@ -57,7 +57,7 @@ public class AutomaticJobRegistrar implements Ordered, SmartLifecycle, Applicati
private boolean autoStartup = true;
private Object lifecycleMonitor = new Object();
private final Object lifecycleMonitor = new Object();
private int order = Ordered.LOWEST_PRECEDENCE;

View File

@@ -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.
@@ -50,15 +50,15 @@ import org.springframework.util.Assert;
*/
public class DefaultJobLoader implements JobLoader, InitializingBean {
private static Log logger = LogFactory.getLog(DefaultJobLoader.class);
private static final Log logger = LogFactory.getLog(DefaultJobLoader.class);
private JobRegistry jobRegistry;
private StepRegistry stepRegistry;
private Map<ApplicationContextFactory, ConfigurableApplicationContext> contexts = new ConcurrentHashMap<>();
private final Map<ApplicationContextFactory, ConfigurableApplicationContext> contexts = new ConcurrentHashMap<>();
private Map<ConfigurableApplicationContext, Collection<String>> contextToJobNames = new ConcurrentHashMap<>();
private final Map<ConfigurableApplicationContext, Collection<String>> contextToJobNames = new ConcurrentHashMap<>();
/**
* Default constructor. Useful for declarative configuration.

View File

@@ -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.
@@ -31,7 +31,7 @@ import org.springframework.batch.core.configuration.JobRegistry;
*/
public class JobFactoryRegistrationListener {
private Log logger = LogFactory.getLog(getClass());
private final Log logger = LogFactory.getLog(getClass());
private JobRegistry jobRegistry;

View File

@@ -48,12 +48,12 @@ import org.springframework.util.Assert;
public class JobRegistryBeanPostProcessor
implements BeanPostProcessor, BeanFactoryAware, InitializingBean, DisposableBean {
private static Log logger = LogFactory.getLog(JobRegistryBeanPostProcessor.class);
private static final Log logger = LogFactory.getLog(JobRegistryBeanPostProcessor.class);
// It doesn't make sense for this to have a default value...
private JobRegistry jobRegistry = null;
private Collection<String> jobNames = new HashSet<>();
private final Collection<String> jobNames = new HashSet<>();
private String groupName = null;

View File

@@ -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.
@@ -27,7 +27,7 @@ import org.springframework.batch.core.configuration.JobFactory;
*/
public class ReferenceJobFactory implements JobFactory {
private Job job;
private final Job job;
/**
* @param job the {@link Job} to return from {@link #createJob()}.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2021-2022 the original author or authors.
* Copyright 2021-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.
@@ -29,9 +29,9 @@ import org.springframework.context.annotation.Configuration;
@Configuration(proxyBeanMethods = false)
public class ScopeConfiguration {
private static StepScope stepScope;
private static final StepScope stepScope;
private static JobScope jobScope;
private static final JobScope jobScope;
static {
jobScope = new JobScope();

View File

@@ -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.
@@ -37,7 +37,7 @@ import org.springframework.util.StringUtils;
*/
public class JobParserJobFactoryBean implements SmartFactoryBean<FlowJob> {
private String name;
private final String name;
private Boolean restartable;

View File

@@ -114,7 +114,7 @@ public class StepParserStepFactoryBean<I, O> implements FactoryBean<Step>, BeanN
private PlatformTransactionManager transactionManager;
private Set<Object> stepExecutionListeners = new LinkedHashSet<>();
private final Set<Object> stepExecutionListeners = new LinkedHashSet<>();
//
// Flow Elements
@@ -154,7 +154,7 @@ public class StepParserStepFactoryBean<I, O> implements FactoryBean<Step>, BeanN
private Isolation isolation;
private Set<ChunkListener> chunkListeners = new LinkedHashSet<>();
private final Set<ChunkListener> chunkListeners = new LinkedHashSet<>();
//
// Chunk Attributes
@@ -204,13 +204,13 @@ public class StepParserStepFactoryBean<I, O> implements FactoryBean<Step>, BeanN
private ItemStream[] streams;
private Set<ItemReadListener<I>> readListeners = new LinkedHashSet<>();
private final Set<ItemReadListener<I>> readListeners = new LinkedHashSet<>();
private Set<ItemWriteListener<O>> writeListeners = new LinkedHashSet<>();
private final Set<ItemWriteListener<O>> writeListeners = new LinkedHashSet<>();
private Set<ItemProcessListener<I, O>> processListeners = new LinkedHashSet<>();
private final Set<ItemProcessListener<I, O>> processListeners = new LinkedHashSet<>();
private Set<SkipListener<I, O>> skipListeners = new LinkedHashSet<>();
private final Set<SkipListener<I, O>> skipListeners = new LinkedHashSet<>();
//
// Additional

View File

@@ -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.
@@ -54,7 +54,7 @@ public abstract class AbstractJobExplorerFactoryBean implements FactoryBean<JobE
private TransactionAttributeSource transactionAttributeSource;
private ProxyFactory proxyFactory = new ProxyFactory();
private final ProxyFactory proxyFactory = new ProxyFactory();
/**
* Creates a job instance data access object (DAO).

View File

@@ -70,7 +70,7 @@ public class JobExplorerFactoryBean extends AbstractJobExplorerFactoryBean imple
private String tablePrefix = AbstractJdbcBatchMetadataDao.DEFAULT_TABLE_PREFIX;
private DataFieldMaxValueIncrementer incrementer = new AbstractDataFieldMaxValueIncrementer() {
private final DataFieldMaxValueIncrementer incrementer = new AbstractDataFieldMaxValueIncrementer() {
@Override
protected long getNextKey() {
throw new IllegalStateException("JobExplorer is read only.");

View File

@@ -82,7 +82,7 @@ public abstract class AbstractJob implements Job, StepLocator, BeanNameAware, In
private JobRepository jobRepository;
private CompositeJobExecutionListener listener = new CompositeJobExecutionListener();
private final CompositeJobExecutionListener listener = new CompositeJobExecutionListener();
private JobParametersIncrementer jobParametersIncrementer;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2019 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.
@@ -43,7 +43,7 @@ import org.springframework.batch.core.step.StepLocator;
*/
public class SimpleJob extends AbstractJob {
private List<Step> steps = new ArrayList<>();
private final List<Step> steps = new ArrayList<>();
/**
* Default constructor for job with null name

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2020 the original author or authors.
* Copyright 2012-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.
@@ -47,27 +47,28 @@ import org.springframework.core.task.TaskExecutor;
*
* @author Dave Syer
* @author Michael Minella
* @author Mahmoud Ben Hassine
* @since 2.2
* @param <Q> the type of object returned by the builder (by default a Flow)
*
*/
public class FlowBuilder<Q> {
private String name;
private final String name;
private String prefix;
private final String prefix;
private List<StateTransition> transitions = new ArrayList<>();
private final List<StateTransition> transitions = new ArrayList<>();
private Map<String, State> tos = new HashMap<>();
private final Map<String, State> tos = new HashMap<>();
private State currentState;
private EndState failedState;
private final EndState failedState;
private EndState completedState;
private final EndState completedState;
private EndState stoppedState;
private final EndState stoppedState;
private int stepCounter = 0;
@@ -79,7 +80,7 @@ public class FlowBuilder<Q> {
private int endCounter = 0;
private Map<Object, State> states = new HashMap<>();
private final Map<Object, State> states = new HashMap<>();
private SimpleFlow flow;
@@ -606,7 +607,7 @@ public class FlowBuilder<Q> {
private final FlowBuilder<Q> parent;
private TaskExecutor executor;
private final TaskExecutor executor;
/**
* @param parent the parent builder

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2013 the original author or authors.
* Copyright 2012-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,11 +22,12 @@ import org.springframework.beans.factory.InitializingBean;
/**
* @author Dave Syer
* @author Mahmoud Ben Hassine
*
*/
public class JobFlowBuilder extends FlowBuilder<FlowJobBuilder> {
private FlowJobBuilder parent;
private final FlowJobBuilder parent;
public JobFlowBuilder(FlowJobBuilder parent) {
super(parent.getName());

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2013 the original author or authors.
* Copyright 2012-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.
@@ -27,12 +27,13 @@ import org.springframework.util.Assert;
/**
* @author Dave Syer
* @author Mahmoud Ben Hassine
* @since 2.2
*
*/
public class SimpleJobBuilder extends JobBuilderHelper<SimpleJobBuilder> {
private List<Step> steps = new ArrayList<>();
private final List<Step> steps = new ArrayList<>();
private JobFlowBuilder builder;

View File

@@ -42,7 +42,7 @@ public class FlowJob extends AbstractJob {
protected Flow flow;
private Map<String, Step> stepMap = new ConcurrentHashMap<>();
private final Map<String, Step> stepMap = new ConcurrentHashMap<>();
private volatile boolean initialized = false;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2021 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.
@@ -56,9 +56,9 @@ public class SimpleFlow implements Flow, InitializingBean {
private State startState;
private Map<String, Set<StateTransition>> transitionMap = new HashMap<>();
private final Map<String, Set<StateTransition>> transitionMap = new HashMap<>();
private Map<String, State> stateMap = new HashMap<>();
private final Map<String, State> stateMap = new HashMap<>();
private List<StateTransition> stateTransitions = new ArrayList<>();

View File

@@ -46,7 +46,7 @@ public class SplitState extends AbstractState implements FlowHolder {
private TaskExecutor taskExecutor = new SyncTaskExecutor();
private FlowExecutionAggregator aggregator = new MaxValueFlowExecutionAggregator();
private final FlowExecutionAggregator aggregator = new MaxValueFlowExecutionAggregator();
/**
* @param flows collection of {@link Flow} instances.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2022 the original author or authors.
* Copyright 2022-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.
@@ -65,7 +65,7 @@ public class JobOperatorFactoryBean implements FactoryBean<JobOperator>, Initial
private JobParametersConverter jobParametersConverter = new DefaultJobParametersConverter();
private ProxyFactory proxyFactory = new ProxyFactory();
private final ProxyFactory proxyFactory = new ProxyFactory();
@Override
public void afterPropertiesSet() throws Exception {

View File

@@ -69,7 +69,7 @@ public class JobRegistryBackgroundJobRunner {
*/
public static final String EMBEDDED = JobRegistryBackgroundJobRunner.class.getSimpleName() + ".EMBEDDED";
private static Log logger = LogFactory.getLog(JobRegistryBackgroundJobRunner.class);
private static final Log logger = LogFactory.getLog(JobRegistryBackgroundJobRunner.class);
private JobLoader jobLoader;
@@ -81,7 +81,7 @@ public class JobRegistryBackgroundJobRunner {
private JobRegistry jobRegistry;
private static List<Exception> errors = Collections.synchronizedList(new ArrayList<>());
private static final List<Exception> errors = Collections.synchronizedList(new ArrayList<>());
/**
* @param parentContextPath the parentContextPath to be used by the

View File

@@ -38,7 +38,7 @@ public class SimpleJvmExitCodeMapper implements ExitCodeMapper {
protected Log logger = LogFactory.getLog(getClass());
private Map<String, Integer> mapping;
private final Map<String, Integer> mapping;
public SimpleJvmExitCodeMapper() {
mapping = new HashMap<>();

View File

@@ -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.
@@ -25,11 +25,12 @@ import org.springframework.core.Ordered;
/**
* @author Lucas Ward
* @author Mahmoud Ben Hassine
*
*/
public class CompositeChunkListener implements ChunkListener {
private OrderedComposite<ChunkListener> listeners = new OrderedComposite<>();
private final OrderedComposite<ChunkListener> listeners = new OrderedComposite<>();
/**
* Default constructor

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2018 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.
@@ -29,7 +29,7 @@ import org.springframework.lang.Nullable;
*/
public class CompositeItemProcessListener<T, S> implements ItemProcessListener<T, S> {
private OrderedComposite<ItemProcessListener<? super T, ? super S>> listeners = new OrderedComposite<>();
private final OrderedComposite<ItemProcessListener<? super T, ? super S>> listeners = new OrderedComposite<>();
/**
* Public setter for the listeners.

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.
@@ -24,11 +24,12 @@ import org.springframework.core.Ordered;
/**
* @author Lucas Ward
* @author Dave Syer
* @author Mahmoud Ben Hassine
*
*/
public class CompositeItemReadListener<T> implements ItemReadListener<T> {
private OrderedComposite<ItemReadListener<? super T>> listeners = new OrderedComposite<>();
private final OrderedComposite<ItemReadListener<? super T>> listeners = new OrderedComposite<>();
/**
* Public setter for the listeners.

View File

@@ -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.
@@ -30,7 +30,7 @@ import org.springframework.core.Ordered;
*/
public class CompositeItemWriteListener<S> implements ItemWriteListener<S> {
private OrderedComposite<ItemWriteListener<? super S>> listeners = new OrderedComposite<>();
private final OrderedComposite<ItemWriteListener<? super S>> listeners = new OrderedComposite<>();
/**
* Public setter for the listeners.

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.
@@ -24,11 +24,12 @@ import org.springframework.core.Ordered;
/**
* @author Dave Syer
* @author Mahmoud Ben Hassine
*
*/
public class CompositeJobExecutionListener implements JobExecutionListener {
private OrderedComposite<JobExecutionListener> listeners = new OrderedComposite<>();
private final OrderedComposite<JobExecutionListener> listeners = new OrderedComposite<>();
/**
* Public setter for the listeners.

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,11 +23,12 @@ import org.springframework.core.Ordered;
/**
* @author Dave Syer
* @author Mahmoud Ben Hassine
*
*/
public class CompositeSkipListener<T, S> implements SkipListener<T, S> {
private OrderedComposite<SkipListener<? super T, ? super S>> listeners = new OrderedComposite<>();
private final OrderedComposite<SkipListener<? super T, ? super S>> listeners = new OrderedComposite<>();
/**
* Public setter for the listeners.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2019 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.
@@ -27,11 +27,12 @@ import org.springframework.lang.Nullable;
/**
* @author Lucas Ward
* @author Dave Syer
* @author Mahmoud Ben Hassine
*
*/
public class CompositeStepExecutionListener implements StepExecutionListener {
private OrderedComposite<StepExecutionListener> list = new OrderedComposite<>();
private final OrderedComposite<StepExecutionListener> list = new OrderedComposite<>();
/**
* Public setter for the listeners.

View File

@@ -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.
@@ -41,17 +41,17 @@ import org.springframework.lang.Nullable;
public class MulticasterBatchListener<T, S> implements StepExecutionListener, ChunkListener, ItemReadListener<T>,
ItemProcessListener<T, S>, ItemWriteListener<S>, SkipListener<T, S> {
private CompositeStepExecutionListener stepListener = new CompositeStepExecutionListener();
private final CompositeStepExecutionListener stepListener = new CompositeStepExecutionListener();
private CompositeChunkListener chunkListener = new CompositeChunkListener();
private final CompositeChunkListener chunkListener = new CompositeChunkListener();
private CompositeItemReadListener<T> itemReadListener = new CompositeItemReadListener<>();
private final CompositeItemReadListener<T> itemReadListener = new CompositeItemReadListener<>();
private CompositeItemProcessListener<T, S> itemProcessListener = new CompositeItemProcessListener<>();
private final CompositeItemProcessListener<T, S> itemProcessListener = new CompositeItemProcessListener<>();
private CompositeItemWriteListener<S> itemWriteListener = new CompositeItemWriteListener<>();
private final CompositeItemWriteListener<S> itemWriteListener = new CompositeItemWriteListener<>();
private CompositeSkipListener<T, S> skipListener = new CompositeSkipListener<>();
private final CompositeSkipListener<T, S> skipListener = new CompositeSkipListener<>();
/**
* Initialize the listener instance.

View File

@@ -33,13 +33,13 @@ import org.springframework.core.annotation.Order;
*/
class OrderedComposite<S> {
private List<S> unordered = new ArrayList<>();
private final List<S> unordered = new ArrayList<>();
private List<S> ordered = new ArrayList<>();
private final List<S> ordered = new ArrayList<>();
private Comparator<? super S> comparator = new AnnotationAwareOrderComparator();
private final Comparator<? super S> comparator = new AnnotationAwareOrderComparator();
private List<S> list = new ArrayList<>();
private final List<S> list = new ArrayList<>();
/**
* Public setter for the listeners.

View File

@@ -129,7 +129,7 @@ public class JdbcJobInstanceDao extends AbstractJdbcBatchMetadataDao implements
private DataFieldMaxValueIncrementer jobInstanceIncrementer;
private JobKeyGenerator<JobParameters> jobKeyGenerator = new DefaultJobKeyGenerator();
private final JobKeyGenerator<JobParameters> jobKeyGenerator = new DefaultJobKeyGenerator();
/**
* In this JDBC implementation a job instance id is obtained by asking the
@@ -235,7 +235,7 @@ public class JdbcJobInstanceDao extends AbstractJdbcBatchMetadataDao implements
ResultSetExtractor<List<JobInstance>> extractor = new ResultSetExtractor<>() {
private List<JobInstance> list = new ArrayList<>();
private final List<JobInstance> list = new ArrayList<>();
@Override
public List<JobInstance> extractData(ResultSet rs) throws SQLException, DataAccessException {
@@ -372,7 +372,7 @@ public class JdbcJobInstanceDao extends AbstractJdbcBatchMetadataDao implements
public List<JobInstance> findJobInstancesByName(String jobName, final int start, final int count) {
@SuppressWarnings("rawtypes")
ResultSetExtractor extractor = new ResultSetExtractor() {
private List<JobInstance> list = new ArrayList<>();
private final List<JobInstance> list = new ArrayList<>();
@Override
public Object extractData(ResultSet rs) throws SQLException, DataAccessException {

View File

@@ -55,7 +55,7 @@ public abstract class AbstractJobRepositoryFactoryBean implements FactoryBean<Jo
private TransactionAttributeSource transactionAttributeSource;
private ProxyFactory proxyFactory = new ProxyFactory();
private final ProxyFactory proxyFactory = new ProxyFactory();
private String isolationLevelForCreate = DEFAULT_ISOLATION_LEVEL;

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.
@@ -52,13 +52,14 @@ import org.springframework.beans.factory.config.Scope;
* @author Dave Syer
* @author Jimmy Praet (create JobScope based on {@link StepScope})
* @author Michael Minella
* @author Mahmoud Ben Hassine
* @since 3.0
*/
public class JobScope extends BatchScopeSupport {
private static final String TARGET_NAME_PREFIX = "jobScopedTarget.";
private Log logger = LogFactory.getLog(getClass());
private final Log logger = LogFactory.getLog(getClass());
private final Object mutex = new Object();

View File

@@ -59,13 +59,14 @@ import org.springframework.beans.factory.config.Scope;
*
* @author Dave Syer
* @author Michael Minella
* @author Mahmoud Ben Hassine
* @since 2.0
*/
public class StepScope extends BatchScopeSupport {
private static final String TARGET_NAME_PREFIX = "scopedTarget.";
private Log logger = LogFactory.getLog(getClass());
private final Log logger = LogFactory.getLog(getClass());
private final Object mutex = new Object();

View File

@@ -49,9 +49,9 @@ import org.springframework.util.Assert;
*/
public class JobContext extends SynchronizedAttributeAccessor {
private JobExecution jobExecution;
private final JobExecution jobExecution;
private Map<String, Set<Runnable>> callbacks = new HashMap<>();
private final Map<String, Set<Runnable>> callbacks = new HashMap<>();
public JobContext(JobExecution jobExecution) {
super();

View File

@@ -51,9 +51,9 @@ import org.springframework.util.Assert;
*/
public class StepContext extends SynchronizedAttributeAccessor {
private StepExecution stepExecution;
private final StepExecution stepExecution;
private Map<String, Set<Runnable>> callbacks = new HashMap<>();
private final Map<String, Set<Runnable>> callbacks = new HashMap<>();
/**
* Create a new instance of {@link StepContext} for this {@link StepExecution}.

View File

@@ -74,7 +74,7 @@ public abstract class AbstractStep implements Step, InitializingBean, BeanNameAw
private boolean allowStartIfComplete = false;
private CompositeStepExecutionListener stepExecutionListener = new CompositeStepExecutionListener();
private final CompositeStepExecutionListener stepExecutionListener = new CompositeStepExecutionListener();
private JobRepository jobRepository;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2022 the original author or authors.
* Copyright 2012-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.
@@ -62,7 +62,7 @@ public abstract class AbstractTaskletStepBuilder<B extends AbstractTaskletStepBu
private TransactionAttribute transactionAttribute;
private Set<ItemStream> streams = new LinkedHashSet<>();
private final Set<ItemStream> streams = new LinkedHashSet<>();
private ExceptionHandler exceptionHandler = new DefaultExceptionHandler();

View File

@@ -94,7 +94,7 @@ import org.springframework.util.Assert;
*/
public class FaultTolerantStepBuilder<I, O> extends SimpleStepBuilder<I, O> {
private ChunkMonitor chunkMonitor = new ChunkMonitor();
private final ChunkMonitor chunkMonitor = new ChunkMonitor();
private boolean streamIsReader;
@@ -102,7 +102,7 @@ public class FaultTolerantStepBuilder<I, O> extends SimpleStepBuilder<I, O> {
private BackOffPolicy backOffPolicy;
private Set<RetryListener> retryListeners = new LinkedHashSet<>();
private final Set<RetryListener> retryListeners = new LinkedHashSet<>();
private RetryPolicy retryPolicy;
@@ -110,17 +110,17 @@ public class FaultTolerantStepBuilder<I, O> extends SimpleStepBuilder<I, O> {
private KeyGenerator keyGenerator;
private Collection<Class<? extends Throwable>> noRollbackExceptionClasses = new LinkedHashSet<>();
private final Collection<Class<? extends Throwable>> noRollbackExceptionClasses = new LinkedHashSet<>();
private Map<Class<? extends Throwable>, Boolean> skippableExceptionClasses = new HashMap<>();
private final Map<Class<? extends Throwable>, Boolean> skippableExceptionClasses = new HashMap<>();
private Collection<Class<? extends Throwable>> nonSkippableExceptionClasses = new HashSet<>();
private Map<Class<? extends Throwable>, Boolean> retryableExceptionClasses = new HashMap<>();
private final Map<Class<? extends Throwable>, Boolean> retryableExceptionClasses = new HashMap<>();
private Collection<Class<? extends Throwable>> nonRetryableExceptionClasses = new HashSet<>();
private Set<SkipListener<? super I, ? super O>> skipListeners = new LinkedHashSet<>();
private final Set<SkipListener<? super I, ? super O>> skipListeners = new LinkedHashSet<>();
private int skipLimit = 0;
@@ -696,7 +696,7 @@ public class FaultTolerantStepBuilder<I, O> extends SimpleStepBuilder<I, O> {
*/
private static class TerminateOnExceptionChunkListenerDelegate implements ChunkListener {
private ChunkListener chunkListener;
private final ChunkListener chunkListener;
TerminateOnExceptionChunkListenerDelegate(ChunkListener chunkListener) {
this.chunkListener = chunkListener;

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.
@@ -31,11 +31,12 @@ import org.springframework.batch.item.support.CompositeItemStream;
* wrapped {@link ItemStream}.
*
* @author Dave Syer
* @author Mahmoud Ben Hassine
* @since 2.0
*/
public class ChunkMonitor extends ItemStreamSupport {
private Log logger = LogFactory.getLog(getClass());
private final Log logger = LogFactory.getLog(getClass());
private boolean streamsRegistered = false;
@@ -54,9 +55,9 @@ public class ChunkMonitor extends ItemStreamSupport {
private static final String OFFSET = "OFFSET";
private CompositeItemStream stream = new CompositeItemStream();
private final CompositeItemStream stream = new CompositeItemStream();
private ThreadLocal<ChunkMonitorData> holder = new ThreadLocal<>();
private final ThreadLocal<ChunkMonitorData> holder = new ThreadLocal<>();
private ItemReader<?> reader;

View File

@@ -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.
@@ -42,7 +42,7 @@ public class ChunkOrientedTasklet<I> implements Tasklet {
private boolean buffering = true;
private static Log logger = LogFactory.getLog(ChunkOrientedTasklet.class);
private static final Log logger = LogFactory.getLog(ChunkOrientedTasklet.class);
public ChunkOrientedTasklet(ChunkProvider<I> chunkProvider, ChunkProcessor<I> chunkProcessor) {
this.chunkProvider = chunkProvider;

View File

@@ -61,7 +61,7 @@ public class FaultTolerantChunkProcessor<I, O> extends SimpleChunkProcessor<I, O
private Classifier<Throwable, Boolean> rollbackClassifier = new BinaryExceptionClassifier(true);
private Log logger = LogFactory.getLog(getClass());
private final Log logger = LogFactory.getLog(getClass());
private boolean buffering = true;

View File

@@ -79,12 +79,12 @@ public class TaskletStep extends AbstractStep {
private RepeatOperations stepOperations = new RepeatTemplate();
private CompositeChunkListener chunkListener = new CompositeChunkListener();
private final CompositeChunkListener chunkListener = new CompositeChunkListener();
// default to checking current thread for interruption.
private StepInterruptionPolicy interruptionPolicy = new ThreadStepInterruptionPolicy();
private CompositeItemStream stream = new CompositeItemStream();
private final CompositeItemStream stream = new CompositeItemStream();
private PlatformTransactionManager transactionManager;

View File

@@ -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.
@@ -218,7 +218,7 @@ public class JobScopeConfigurationTests {
public static class Wrapper {
private SimpleHolder value;
private final SimpleHolder value;
public Wrapper(SimpleHolder value) {
this.value = value;

View File

@@ -238,7 +238,7 @@ public class StepScopeConfigurationTests {
public static class Wrapper {
private SimpleHolder value;
private final SimpleHolder value;
public Wrapper(SimpleHolder value) {
this.value = value;

View File

@@ -83,7 +83,7 @@ public class PartitionStepParserTests implements ApplicationContextAware {
private ApplicationContext applicationContext;
private List<String> savedStepNames = new ArrayList<>();
private final List<String> savedStepNames = new ArrayList<>();
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2019 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.
@@ -44,7 +44,7 @@ import org.springframework.util.ClassUtils;
*/
public class JobSupport implements BeanNameAware, Job, StepLocator {
private Map<String, Step> steps = new HashMap<>();
private final Map<String, Step> steps = new HashMap<>();
private String name;

View File

@@ -537,7 +537,7 @@ class SimpleJobTests {
private Throwable exception;
private JobRepository jobRepository;
private final JobRepository jobRepository;
private ExecutionContext passedInStepContext;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2010-2022 the original author or authors.
* Copyright 2010-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.
@@ -50,7 +50,7 @@ import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder;
*/
class FlowJobFailureTests {
private FlowJob job = new FlowJob();
private final FlowJob job = new FlowJob();
private JobExecution execution;

View File

@@ -170,7 +170,7 @@ class CommandLineJobRunnerTests {
@Test
void testWithStdinCommandLine() throws Throwable {
System.setIn(new InputStream() {
char[] input = (jobPath + "\n" + jobName + "\nfoo=bar\nspam=bucket").toCharArray();
final char[] input = (jobPath + "\n" + jobName + "\nfoo=bar\nspam=bucket").toCharArray();
int index = 0;
@@ -192,7 +192,7 @@ class CommandLineJobRunnerTests {
@Test
void testWithStdinCommandLineWithEmptyLines() throws Throwable {
System.setIn(new InputStream() {
char[] input = (jobPath + "\n" + jobName + "\nfoo=bar\n\nspam=bucket\n\n").toCharArray();
final char[] input = (jobPath + "\n" + jobName + "\nfoo=bar\n\nspam=bucket\n\n").toCharArray();
int index = 0;
@@ -215,7 +215,7 @@ class CommandLineJobRunnerTests {
void testWithStdinParameters() throws Throwable {
String[] args = new String[] { jobPath, jobName };
System.setIn(new InputStream() {
char[] input = ("foo=bar\nspam=bucket").toCharArray();
final char[] input = ("foo=bar\nspam=bucket").toCharArray();
int index = 0;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2022 the original author or authors.
* Copyright 2022-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.
@@ -39,17 +39,17 @@ import org.springframework.transaction.interceptor.TransactionInterceptor;
*/
class JobOperatorFactoryBeanTests {
private PlatformTransactionManager transactionManager = Mockito.mock(PlatformTransactionManager.class);
private final PlatformTransactionManager transactionManager = Mockito.mock(PlatformTransactionManager.class);
private JobRepository jobRepository = Mockito.mock(JobRepository.class);
private final JobRepository jobRepository = Mockito.mock(JobRepository.class);
private JobLauncher jobLauncher = Mockito.mock(JobLauncher.class);
private final JobLauncher jobLauncher = Mockito.mock(JobLauncher.class);
private JobRegistry jobRegistry = Mockito.mock(JobRegistry.class);
private final JobRegistry jobRegistry = Mockito.mock(JobRegistry.class);
private JobExplorer jobExplorer = Mockito.mock(JobExplorer.class);
private final JobExplorer jobExplorer = Mockito.mock(JobExplorer.class);
private JobParametersConverter jobParametersConverter = Mockito.mock(JobParametersConverter.class);
private final JobParametersConverter jobParametersConverter = Mockito.mock(JobParametersConverter.class);
@Test
public void testJobOperatorCreation() throws Exception {

View File

@@ -229,7 +229,7 @@ class ItemListenerErrorTests {
private boolean goingToFail = false;
private ItemReader<String> delegate = new ListItemReader<>(Collections.singletonList("1"));
private final ItemReader<String> delegate = new ListItemReader<>(Collections.singletonList("1"));
private int count = 0;

View File

@@ -550,7 +550,7 @@ class MulticasterBatchListenerTests {
private static final class AnnotationBasedStepListener {
private IllegalStateException exception = new IllegalStateException("listener error");
private final IllegalStateException exception = new IllegalStateException("listener error");
@BeforeRead
public void beforeRead() {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2008-2019 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.
@@ -29,9 +29,9 @@ import org.springframework.util.ClassUtils;
*/
public class ExampleItemReader extends AbstractItemStreamItemReader<String> {
private Log logger = LogFactory.getLog(getClass());
private final Log logger = LogFactory.getLog(getClass());
private String[] input = { "Hello", "world!", "Go", "on", "punk", "make", "my", "day!" };
private final String[] input = { "Hello", "world!", "Go", "on", "punk", "make", "my", "day!" };
private int index = 0;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2008-2022 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.
@@ -31,7 +31,7 @@ public class ExampleItemWriter implements ItemWriter<String> {
private static final Log log = LogFactory.getLog(ExampleItemWriter.class);
private static List<String> items = new ArrayList<>();
private static final List<String> items = new ArrayList<>();
public static void clear() {
items.clear();

View File

@@ -44,7 +44,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
*/
class PartitionStepTests {
private PartitionStep step = new PartitionStep();
private final PartitionStep step = new PartitionStep();
private JobRepository jobRepository;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2009-2022 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.
@@ -101,7 +101,7 @@ class NonAbstractStepTests {
*/
private class EventTrackingListener implements StepExecutionListener {
private String name;
private final String name;
public EventTrackingListener(String name) {
this.name = name;

View File

@@ -260,7 +260,7 @@ class RegisterMultiListenerTests {
private static class MultiListener
implements StepExecutionListener, ChunkListener, ItemWriteListener<String>, SkipListener<String, String> {
private CallChecker callChecker;
private final CallChecker callChecker;
private MultiListener(CallChecker callChecker) {
super();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2019 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.
@@ -29,15 +29,16 @@ import org.springframework.lang.Nullable;
/**
* @author Dan Garrette
* @author Mahmoud Ben Hassine
* @since 2.0.2
*/
public class ExceptionThrowingTaskletStub implements Tasklet {
private int maxTries = 4;
private final int maxTries = 4;
protected Log logger = LogFactory.getLog(getClass());
private List<Integer> committed = TransactionAwareProxyFactory.createTransactionalList();
private final List<Integer> committed = TransactionAwareProxyFactory.createTransactionalList();
private Constructor<? extends Exception> exception;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2008-2022 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.
@@ -126,7 +126,7 @@ class FaultTolerantStepFactoryBeanNonBufferingTests {
protected final Log logger = LogFactory.getLog(getClass());
// simulate transactional output
private List<Object> written = TransactionAwareProxyFactory.createTransactionalList();
private final List<Object> written = TransactionAwareProxyFactory.createTransactionalList();
private final Collection<String> failures;

View File

@@ -73,13 +73,13 @@ class FaultTolerantStepFactoryBeanRetryTests {
private FaultTolerantStepFactoryBean<String, String> factory;
private List<Object> recovered = new ArrayList<>();
private final List<Object> recovered = new ArrayList<>();
private List<Object> processed = new ArrayList<>();
private final List<Object> processed = new ArrayList<>();
private List<Object> provided = new ArrayList<>();
private final List<Object> provided = new ArrayList<>();
private List<Object> written = TransactionAwareProxyFactory.createTransactionalList();
private final List<Object> written = TransactionAwareProxyFactory.createTransactionalList();
int count = 0;
@@ -89,7 +89,7 @@ class FaultTolerantStepFactoryBeanRetryTests {
JobExecution jobExecution;
private ItemWriter<String> writer = data -> processed.addAll(data.getItems());
private final ItemWriter<String> writer = data -> processed.addAll(data.getItems());
@SuppressWarnings("unchecked")
@BeforeEach

View File

@@ -278,7 +278,7 @@ class SimpleStepFactoryBeanTests {
int failedCount = 0;
private AssertingWriteListener writeListener;
private final AssertingWriteListener writeListener;
public CountingChunkListener(AssertingWriteListener writeListener) {
super();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2019 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.
@@ -24,13 +24,14 @@ import org.springframework.lang.Nullable;
/**
* @author Dan Garrette
* @author Mahmoud Ben Hassine
* @since 2.0.1
*/
public class SkipProcessorStub<T> extends AbstractExceptionThrowingItemHandlerStub<T> implements ItemProcessor<T, T> {
private List<T> processed = new ArrayList<>();
private final List<T> processed = new ArrayList<>();
private List<T> committed = TransactionAwareProxyFactory.createTransactionalList();
private final List<T> committed = TransactionAwareProxyFactory.createTransactionalList();
private boolean filter = false;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2019 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.
@@ -26,13 +26,14 @@ import org.springframework.util.Assert;
/**
* @author Dan Garrette
* @author Mahmoud Ben Hassine
* @since 2.0.1
*/
public class SkipReaderStub<T> extends AbstractExceptionThrowingItemHandlerStub<T> implements ItemReader<T> {
private T[] items;
private List<T> read = new ArrayList<>();
private final List<T> read = new ArrayList<>();
private int counter = -1;

View File

@@ -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.
@@ -29,9 +29,9 @@ import org.springframework.batch.support.transaction.TransactionAwareProxyFactor
*/
public class SkipWriterStub<T> extends AbstractExceptionThrowingItemHandlerStub<T> implements ItemWriter<T> {
private List<T> written = new ArrayList<>();
private final List<T> written = new ArrayList<>();
private List<T> committed = TransactionAwareProxyFactory.createTransactionalList();
private final List<T> committed = TransactionAwareProxyFactory.createTransactionalList();
public SkipWriterStub() throws Exception {
super();

View File

@@ -934,7 +934,7 @@ class TaskletStepTests {
private boolean getExecutionAttributesCalled = false;
private boolean restoreFromCalled = false;
private final boolean restoreFromCalled = false;
@Nullable
@Override

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2019 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.
@@ -40,7 +40,7 @@ import org.springframework.util.ClassUtils;
*/
public class JobSupport implements BeanNameAware, Job {
private List<Step> steps = new ArrayList<>();
private final List<Step> steps = new ArrayList<>();
private String name;

View File

@@ -199,11 +199,11 @@ class FaultTolerantStepFactoryBeanIntegrationTests {
private static class SkipWriterStub implements ItemWriter<String> {
private List<String> written = new ArrayList<>();
private final List<String> written = new ArrayList<>();
private Collection<String> failures = Collections.emptySet();
private final Collection<String> failures = Collections.emptySet();
private JdbcTemplate jdbcTemplate;
private final JdbcTemplate jdbcTemplate;
public SkipWriterStub(DataSource dataSource) {
jdbcTemplate = new JdbcTemplate(dataSource);
@@ -240,9 +240,9 @@ class FaultTolerantStepFactoryBeanIntegrationTests {
private final Log logger = LogFactory.getLog(getClass());
private List<String> processed = new ArrayList<>();
private final List<String> processed = new ArrayList<>();
private JdbcTemplate jdbcTemplate;
private final JdbcTemplate jdbcTemplate;
/**
* @param dataSource

View File

@@ -221,11 +221,11 @@ class FaultTolerantStepFactoryBeanRollbackIntegrationTests {
private static class SkipWriterStub implements ItemWriter<String> {
private List<String> written = new CopyOnWriteArrayList<>();
private final List<String> written = new CopyOnWriteArrayList<>();
private Collection<String> failures = Collections.emptySet();
private JdbcTemplate jdbcTemplate;
private final JdbcTemplate jdbcTemplate;
public SkipWriterStub(DataSource dataSource) {
jdbcTemplate = new JdbcTemplate(dataSource);
@@ -266,9 +266,9 @@ class FaultTolerantStepFactoryBeanRollbackIntegrationTests {
private final Log logger = LogFactory.getLog(getClass());
private List<String> processed = new CopyOnWriteArrayList<>();
private final List<String> processed = new CopyOnWriteArrayList<>();
private JdbcTemplate jdbcTemplate;
private final JdbcTemplate jdbcTemplate;
/**
* @param dataSource