Code cleanup

- Inline variables
- Remove unused variables
- Remove redundant array creation
- Remove redundant `@SuppressWarnings`
- Remove unnecessary exceptions from throws list
- Remove redundant initializers
- Use List.subList().clear() where appropriate
- Use try-with-resources where needed
- Use pattern variables where appropriate
This commit is contained in:
Mahmoud Ben Hassine
2023-07-12 23:25:18 +02:00
parent 4763480c57
commit 52064c0541
103 changed files with 169 additions and 224 deletions

View File

@@ -30,7 +30,6 @@ import org.springframework.util.ClassUtils;
* @author Mahmoud Ben Hassine
*
*/
@SuppressWarnings("serial")
public class Entity implements Serializable {
private Long id;

View File

@@ -27,9 +27,9 @@ import java.io.StringWriter;
* {@code ExitStatus} is immutable and, therefore, thread-safe.
*
* @author Dave Syer
* @author Mahmoud Ben Hassine
*
*/
@SuppressWarnings("serial")
public class ExitStatus implements Serializable, Comparable<ExitStatus> {
/**

View File

@@ -41,7 +41,6 @@ import org.springframework.lang.Nullable;
* @author Taeik Lim
*
*/
@SuppressWarnings("serial")
public class JobExecution extends Entity {
private final JobParameters jobParameters;

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.
@@ -22,9 +22,9 @@ package org.springframework.batch.core;
* instructions and the data.
*
* @author Dave Syer
* @author Mahmoud Ben Hassine
*
*/
@SuppressWarnings("serial")
public class JobExecutionException extends Exception {
/**

View File

@@ -37,7 +37,6 @@ import org.springframework.util.Assert;
* @author Mahmoud Ben Hassine
*
*/
@SuppressWarnings("serial")
public class JobInstance extends Entity {
private final String jobName;

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.
@@ -24,9 +24,9 @@ package org.springframework.batch.core;
*
* @author Lucas Ward
* @author Dave Syer
* @author Mahmoud Ben Hassine
*
*/
@SuppressWarnings("serial")
public class JobInterruptedException extends JobExecutionException {
private BatchStatus status = BatchStatus.STOPPED;

View File

@@ -49,7 +49,6 @@ import org.springframework.util.Assert;
* @author Taeik Lim
* @since 1.0
*/
@SuppressWarnings("serial")
public class JobParameters implements Serializable {
private final Map<String, JobParameter<?>> parameters;
@@ -339,7 +338,7 @@ public class JobParameters implements Serializable {
@Override
public boolean equals(Object obj) {
if (obj instanceof JobParameters == false) {
if (!(obj instanceof JobParameters rhs)) {
return false;
}
@@ -347,7 +346,6 @@ public class JobParameters implements Serializable {
return true;
}
JobParameters rhs = (JobParameters) obj;
return this.parameters.equals(rhs.parameters);
}

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.
@@ -19,9 +19,9 @@ package org.springframework.batch.core;
* Exception for {@link Job} to signal that some {@link JobParameters} are invalid.
*
* @author Dave Syer
* @author Mahmoud Ben Hassine
*
*/
@SuppressWarnings("serial")
public class JobParametersInvalidException extends JobExecutionException {
/**

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.
@@ -19,7 +19,6 @@ package org.springframework.batch.core;
/**
* Indicates the step's start limit has been exceeded.
*/
@SuppressWarnings("serial")
public class StartLimitExceededException extends RuntimeException {
/**

View File

@@ -25,7 +25,6 @@ import java.io.Serializable;
* @author Mahmoud Ben Hassine
*
*/
@SuppressWarnings("serial")
public class StepContribution implements Serializable {
private volatile long readCount = 0;

View File

@@ -38,7 +38,6 @@ import org.springframework.util.Assert;
* @author Taeik Lim
*
*/
@SuppressWarnings("serial")
public class StepExecution extends Entity {
private final JobExecution jobExecution;

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.
@@ -22,9 +22,9 @@ import org.springframework.batch.core.JobExecutionException;
* Checked exception that indicates a name clash when registering {@link Job} instances.
*
* @author Dave Syer
* @author Mahmoud Ben Hassine
*
*/
@SuppressWarnings("serial")
public class DuplicateJobException extends JobExecutionException {
/**

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,6 +25,7 @@ import org.springframework.context.ConfigurableApplicationContext;
* out when asked to create a {@link Job}.
*
* @author Dave Syer
* @author Mahmoud Ben Hassine
*
*/
public class ApplicationContextJobFactory implements JobFactory {
@@ -37,7 +38,6 @@ public class ApplicationContextJobFactory implements JobFactory {
* a job with the job name provided.
*/
public ApplicationContextJobFactory(String jobName, ApplicationContextFactory applicationContextFactory) {
@SuppressWarnings("resource")
ConfigurableApplicationContext context = applicationContextFactory.createApplicationContext();
this.job = context.getBean(jobName, Job.class);
}

View File

@@ -21,9 +21,6 @@ import java.sql.Types;
import javax.sql.DataSource;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.batch.core.configuration.BatchConfigurationException;
import org.springframework.batch.core.configuration.JobRegistry;
import org.springframework.batch.core.converter.DateToStringConverter;
@@ -114,8 +111,6 @@ import org.springframework.transaction.annotation.Isolation;
@Import(ScopeConfiguration.class)
public class DefaultBatchConfiguration implements ApplicationContextAware {
private static final Log LOGGER = LogFactory.getLog(DefaultBatchConfiguration.class);
@Autowired
protected ApplicationContext applicationContext;

View File

@@ -149,7 +149,6 @@ public class DefaultJobLoader implements JobLoader, InitializingBean {
return doLoad(factory, false);
}
@SuppressWarnings("resource")
private Collection<Job> doLoad(ApplicationContextFactory factory, boolean unregister) throws DuplicateJobException {
Collection<String> jobNamesBefore = jobRegistry.getJobNames();

View File

@@ -465,7 +465,6 @@ public class StepParserStepFactoryBean<I, O> implements FactoryBean<Step>, BeanN
* established for the factory bean.
* @param builder The {@link AbstractTaskletStepBuilder} to be modified.
*/
@SuppressWarnings("serial")
protected void enhanceTaskletStepBuilder(AbstractTaskletStepBuilder<?> builder) {
enhanceCommonStep(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.
@@ -17,10 +17,10 @@ package org.springframework.batch.core.job.builder;
/**
* @author Dave Syer
* @author Mahmoud Ben Hassine
* @since 2.2
*
*/
@SuppressWarnings("serial")
public class FlowBuilderException extends RuntimeException {
public FlowBuilderException(String msg, Exception e) {

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.
@@ -17,10 +17,10 @@ package org.springframework.batch.core.job.builder;
/**
* @author Dave Syer
* @author Mahmoud Ben Hassine
* @since 2.2
*
*/
@SuppressWarnings("serial")
public class JobBuilderException extends RuntimeException {
public JobBuilderException(Exception e) {

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.
@@ -17,9 +17,9 @@ package org.springframework.batch.core.job.flow;
/**
* @author Dave Syer
* @author Mahmoud Ben Hassine
*
*/
@SuppressWarnings("serial")
public class FlowExecutionException extends Exception {
/**

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2007 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,9 +22,9 @@ import org.springframework.batch.core.JobExecutionException;
* actually it didn't fail.
*
* @author Dave Syer
* @author Mahmoud Ben Hassine
*
*/
@SuppressWarnings("serial")
public class JobExecutionNotFailedException extends JobExecutionException {
/**

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2007 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,9 +22,9 @@ import org.springframework.batch.core.JobExecutionException;
* requested to stop.
*
* @author Dave Syer
* @author Mahmoud Ben Hassine
* @since 2.0
*/
@SuppressWarnings("serial")
public class JobExecutionNotRunningException extends JobExecutionException {
/**

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2007 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,9 +22,9 @@ import org.springframework.batch.core.JobExecutionException;
* hasn't been stopped.
*
* @author Dave Syer
* @author Mahmoud Ben Hassine
*
*/
@SuppressWarnings("serial")
public class JobExecutionNotStoppedException extends JobExecutionException {
/**

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2007 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,9 +22,9 @@ import org.springframework.batch.core.JobExecutionException;
* Checked exception to indicate that a required {@link Job} is not available.
*
* @author Dave Syer
* @author Mahmoud Ben Hassine
*
*/
@SuppressWarnings("serial")
public class JobInstanceAlreadyExistsException extends JobExecutionException {
/**

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2007 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,9 +23,9 @@ import org.springframework.batch.core.JobParametersIncrementer;
* available.
*
* @author Dave Syer
* @author Mahmoud Ben Hassine
*
*/
@SuppressWarnings("serial")
public class JobParametersNotFoundException extends JobExecutionException {
/**

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2007 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,9 +22,9 @@ import org.springframework.batch.core.JobExecutionException;
* Checked exception to indicate that a required {@link Job} is not available.
*
* @author Dave Syer
* @author Mahmoud Ben Hassine
*
*/
@SuppressWarnings("serial")
public class NoSuchJobException extends JobExecutionException {
/**

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2007 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,9 +22,9 @@ import org.springframework.batch.core.JobExecutionException;
* Checked exception to indicate that a required {@link JobExecution} is not available.
*
* @author Dave Syer
* @author Mahmoud Ben Hassine
*
*/
@SuppressWarnings("serial")
public class NoSuchJobExecutionException extends JobExecutionException {
/**

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2007 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,9 +23,9 @@ import org.springframework.batch.core.JobInstance;
* {@link JobInstance}.
*
* @author Dave Syer
* @author Mahmoud Ben Hassine
*
*/
@SuppressWarnings("serial")
public class NoSuchJobInstanceException extends JobExecutionException {
/**

View File

@@ -192,8 +192,7 @@ public class CommandLineJobRunner {
private JobRepository jobRepository;
private final static List<String> VALID_OPTS = Arrays
.asList(new String[] { "-restart", "-next", "-stop", "-abandon" });
private final static List<String> VALID_OPTS = Arrays.asList("-restart", "-next", "-stop", "-abandon");
/**
* Injection setter for the {@link JobLauncher}.
@@ -284,7 +283,6 @@ public class CommandLineJobRunner {
* If a JobLocator has been set, then use it to obtain an actual job, if not ask the
* context for it.
*/
@SuppressWarnings("resource")
int start(String jobPath, String jobIdentifier, String[] parameters, Set<String> opts) {
ConfigurableApplicationContext context = null;

View File

@@ -54,7 +54,7 @@ public class RunIdIncrementer implements JobParametersIncrementer {
public JobParameters getNext(@Nullable JobParameters parameters) {
JobParameters params = (parameters == null) ? new JobParameters() : parameters;
JobParameter runIdParameter = params.getParameters().get(this.key);
JobParameter<?> runIdParameter = params.getParameters().get(this.key);
long id = 1;
if (runIdParameter != null) {
try {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2012 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.
@@ -20,9 +20,9 @@ package org.springframework.batch.core.listener;
*
* @author Dave Syer
* @author Michael Minella
* @author Mahmoud Ben Hassine
*
*/
@SuppressWarnings("serial")
public class StepListenerFailedException extends RuntimeException {
/**

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2007 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.
@@ -19,9 +19,9 @@ import org.springframework.batch.core.JobExecutionException;
/**
* @author Dave Syer
* @author Mahmoud Ben Hassine
*
*/
@SuppressWarnings("serial")
public class JobExecutionAlreadyRunningException extends JobExecutionException {
/**

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2007 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,9 +22,9 @@ import org.springframework.batch.core.JobExecutionException;
* successfully.
*
* @author Dave Syer
* @author Mahmoud Ben Hassine
*
*/
@SuppressWarnings("serial")
public class JobInstanceAlreadyCompleteException extends JobExecutionException {
/**

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2007 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.
@@ -21,9 +21,9 @@ import org.springframework.batch.core.JobExecutionException;
* An exception indicating an illegal attempt to restart a job.
*
* @author Dave Syer
* @author Mahmoud Ben Hassine
*
*/
@SuppressWarnings("serial")
public class JobRestartException extends JobExecutionException {
/**

View File

@@ -350,7 +350,7 @@ public class JdbcExecutionContextDao extends AbstractJdbcBatchMetadataDao implem
}
ByteArrayOutputStream out = new ByteArrayOutputStream();
String results = "";
String results;
try {
serializer.serialize(m, out);

View File

@@ -354,9 +354,8 @@ public class JdbcJobExecutionDao extends AbstractJdbcBatchMetadataDao implements
@Nullable
public JobExecution getJobExecution(Long executionId) {
try {
JobExecution jobExecution = getJdbcTemplate().queryForObject(getQuery(GET_EXECUTION_BY_ID),
new JobExecutionRowMapper(), executionId);
return jobExecution;
return getJdbcTemplate().queryForObject(getQuery(GET_EXECUTION_BY_ID), new JobExecutionRowMapper(),
executionId);
}
catch (EmptyResultDataAccessException e) {
return null;

View File

@@ -253,9 +253,7 @@ public class JdbcJobInstanceDao extends AbstractJdbcBatchMetadataDao implements
};
List<JobInstance> result = getJdbcTemplate().query(getQuery(FIND_LAST_JOBS_BY_NAME), extractor, jobName);
return result;
return getJdbcTemplate().query(getQuery(FIND_LAST_JOBS_BY_NAME), extractor, jobName);
}
/*
@@ -369,8 +367,8 @@ public class JdbcJobInstanceDao extends AbstractJdbcBatchMetadataDao implements
}
@Override
@SuppressWarnings({ "rawtypes", "unchecked" })
public List<JobInstance> findJobInstancesByName(String jobName, final int start, final int count) {
@SuppressWarnings("rawtypes")
ResultSetExtractor extractor = new ResultSetExtractor() {
private final List<JobInstance> list = new ArrayList<>();
@@ -393,11 +391,8 @@ public class JdbcJobInstanceDao extends AbstractJdbcBatchMetadataDao implements
jobName = jobName.replaceAll("\\" + STAR_WILDCARD, SQL_WILDCARD);
}
@SuppressWarnings("unchecked")
List<JobInstance> result = (List<JobInstance>) getJdbcTemplate().query(getQuery(FIND_LAST_JOBS_LIKE_NAME),
extractor, jobName);
return (List<JobInstance>) getJdbcTemplate().query(getQuery(FIND_LAST_JOBS_LIKE_NAME), extractor, jobName);
return result;
}
}

View File

@@ -230,9 +230,7 @@ public class JobRepositoryFactoryBean extends AbstractJobRepositoryFactoryBean i
}
if (serializer == null) {
DefaultExecutionContextSerializer defaultSerializer = new DefaultExecutionContextSerializer();
serializer = defaultSerializer;
serializer = new DefaultExecutionContextSerializer();
}
Assert.state(incrementerFactory.isSupportedIncrementerType(databaseType),
@@ -315,7 +313,7 @@ public class JobRepositoryFactoryBean extends AbstractJobRepositoryFactoryBean i
return dao;
}
private int determineClobTypeToUse(String databaseType) throws Exception {
private int determineClobTypeToUse(String databaseType) {
if (clobType != null) {
return clobType;
}

View File

@@ -341,9 +341,7 @@ public class SimpleJobRepository implements JobRepository {
Assert.notNull(jobName, "A job name is required to create a JobInstance");
Assert.notNull(jobParameters, "Job parameters are required to create a JobInstance");
JobInstance jobInstance = jobInstanceDao.createJobInstance(jobName, jobParameters);
return jobInstance;
return jobInstanceDao.createJobInstance(jobName, jobParameters);
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2007 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,9 +26,9 @@ import org.springframework.core.AttributeAccessorSupport;
* chunk is retried the same context will be associated with it.
*
* @author Dave Syer
* @author Mahmoud Ben Hassine
*
*/
@SuppressWarnings("serial")
public class ChunkContext extends AttributeAccessorSupport {
private final StepContext stepContext;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2010 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.
@@ -19,9 +19,9 @@ import org.springframework.batch.core.UnexpectedJobExecutionException;
/**
* @author Dave Syer
* @author Mahmoud Ben Hassine
*
*/
@SuppressWarnings("serial")
public class FatalStepExecutionException extends UnexpectedJobExecutionException {
/**

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2007 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.
@@ -19,9 +19,9 @@ package org.springframework.batch.core.step;
* Exception to signal that a step was requested that is unknown or does not exist.
*
* @author Dave Syer
* @author Mahmoud Ben Hassine
*
*/
@SuppressWarnings("serial")
public class NoSuchStepException extends RuntimeException {
/**

View File

@@ -276,8 +276,7 @@ public abstract class AbstractTaskletStepBuilder<B extends AbstractTaskletStepBu
* @return true if the tasklet is going to be run in multiple threads
*/
protected boolean concurrent() {
boolean concurrent = taskExecutor != null && !(taskExecutor instanceof SyncTaskExecutor);
return concurrent;
return taskExecutor != null && !(taskExecutor instanceof SyncTaskExecutor);
}
protected TaskExecutor getTaskExecutor() {

View File

@@ -535,7 +535,6 @@ public class FaultTolerantStepBuilder<I, O> extends SimpleStepBuilder<I, O> {
}
@SuppressWarnings("serial")
private TransactionAttribute getTransactionAttribute(TransactionAttribute attribute) {
final Classifier<Throwable, Boolean> classifier = getRollbackClassifier();
@@ -738,7 +737,6 @@ public class FaultTolerantStepBuilder<I, O> extends SimpleStepBuilder<I, O> {
return chunkListener.hashCode();
}
@SuppressWarnings("unchecked")
@Override
public boolean equals(Object obj) {
if (obj instanceof FaultTolerantStepBuilder.TerminateOnExceptionChunkListenerDelegate) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2011 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.
@@ -19,9 +19,9 @@ package org.springframework.batch.core.step.builder;
* Utility exception thrown by builders when they encounter unexpected checked exceptions.
*
* @author Dave Syer
* @author Mahmoud Ben Hassine
* @since 2.2
*/
@SuppressWarnings("serial")
public class StepBuilderException extends RuntimeException {
public StepBuilderException(Exception e) {

View File

@@ -294,7 +294,6 @@ public class SimpleStepFactoryBean<T, S> implements FactoryBean<Step>, BeanNameA
* Getter for the {@link TransactionAttribute} for subclasses only.
* @return the transactionAttribute
*/
@SuppressWarnings("serial")
protected TransactionAttribute getTransactionAttribute() {
DefaultTransactionAttribute attribute = new DefaultTransactionAttribute();
@@ -326,8 +325,7 @@ public class SimpleStepFactoryBean<T, S> implements FactoryBean<Step>, BeanNameA
public final Step getObject() throws Exception {
SimpleStepBuilder<T, S> builder = createBuilder(getName());
applyConfiguration(builder);
TaskletStep step = builder.build();
return step;
return builder.build();
}
protected SimpleStepBuilder<T, S> createBuilder(String name) {

View File

@@ -68,7 +68,6 @@ public class BatchRetryTemplate implements RetryOperations {
}
@SuppressWarnings("serial")
private static class BatchRetryContext extends RetryContextSupport {
private final Collection<RetryContext> contexts;

View File

@@ -41,7 +41,7 @@ public class DefaultItemFailureHandler extends ItemListenerSupport<Object, Objec
logger.error("Error encountered while reading", ex);
}
catch (Exception exception) {
logger.error("Invalid type for logging: [" + exception.toString() + "]");
logger.error("Invalid type for logging: [" + exception + "]");
}
}
@@ -51,7 +51,7 @@ public class DefaultItemFailureHandler extends ItemListenerSupport<Object, Objec
logger.error("Error encountered while writing item: [ " + item + "]", ex);
}
catch (Exception exception) {
logger.error("Invalid type for logging: [" + exception.toString() + "]");
logger.error("Invalid type for logging: [" + exception + "]");
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2007 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.
@@ -21,9 +21,9 @@ package org.springframework.batch.core.step.item;
* an exception that otherwise would not cause a rollback.
*
* @author Dave Syer
* @author Mahmoud Ben Hassine
*
*/
@SuppressWarnings("serial")
public class ForceRollbackForWriteSkipException extends RuntimeException {
public ForceRollbackForWriteSkipException(String msg, Throwable cause) {

View File

@@ -125,7 +125,7 @@ public class SimpleChunkProvider<I> implements ChunkProvider<I> {
final Chunk<I> inputs = new Chunk<>();
repeatOperations.iterate(context -> {
I item = null;
I item;
Timer.Sample sample = Timer.start(Metrics.globalRegistry);
String status = BatchMetrics.STATUS_SUCCESS;
try {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2009 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.
@@ -20,9 +20,9 @@ import org.springframework.batch.core.step.skip.SkipException;
/**
* @author Dave Syer
* @author Mahmoud Ben Hassine
*
*/
@SuppressWarnings("serial")
public class SkipOverflowException extends SkipException {
/**

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.
@@ -49,9 +49,7 @@ public class ExceptionClassifierSkipPolicy implements SkipPolicy {
* a {@link Classifier} to locate a policy.
*/
public void setPolicyMap(Map<Class<? extends Throwable>, SkipPolicy> policyMap) {
SubclassClassifier<Throwable, SkipPolicy> subclassClassifier = new SubclassClassifier<>(policyMap,
new NeverSkipItemSkipPolicy());
this.classifier = subclassClassifier;
this.classifier = new SubclassClassifier<>(policyMap, new NeverSkipItemSkipPolicy());
}
/**

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2007 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.
@@ -20,9 +20,9 @@ package org.springframework.batch.core.step.skip;
* Fatal exception to be thrown when a process operation could not be skipped.
*
* @author Dave Syer
* @author Mahmoud Ben Hassine
*
*/
@SuppressWarnings("serial")
public class NonSkippableProcessException extends SkipException {
public NonSkippableProcessException(String msg, Throwable cause) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2007 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.
@@ -20,9 +20,9 @@ package org.springframework.batch.core.step.skip;
* Fatal exception to be thrown when a read operation could not be skipped.
*
* @author Dave Syer
* @author Mahmoud Ben Hassine
*
*/
@SuppressWarnings("serial")
public class NonSkippableReadException extends SkipException {
public NonSkippableReadException(String msg, Throwable cause) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2007 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.
@@ -20,9 +20,9 @@ package org.springframework.batch.core.step.skip;
* Fatal exception to be thrown when a process operation could not be skipped.
*
* @author Dave Syer
* @author Mahmoud Ben Hassine
*
*/
@SuppressWarnings("serial")
public class NonSkippableWriteException extends SkipException {
public NonSkippableWriteException(String msg, Throwable cause) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2007 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.
@@ -21,8 +21,8 @@ import org.springframework.batch.core.UnexpectedJobExecutionException;
* Base exception indicating that the skip has failed or caused a failure.
*
* @author Dave Syer
* @author Mahmoud Ben Hassine
*/
@SuppressWarnings("serial")
public abstract class SkipException extends UnexpectedJobExecutionException {
/**

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.
@@ -24,7 +24,6 @@ package org.springframework.batch.core.step.skip;
* @author Dave Syer
* @author Mahmoud Ben Hassine
*/
@SuppressWarnings("serial")
public class SkipLimitExceededException extends SkipException {
private final long skipLimit;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2007 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,9 +23,9 @@ import org.springframework.batch.core.UnexpectedJobExecutionException;
* treatment in the framework in case a skip sends itself into an infinite loop.
*
* @author Dave Syer
* @author Mahmoud Ben Hassine
*
*/
@SuppressWarnings("serial")
public class SkipListenerFailedException extends UnexpectedJobExecutionException {
/**

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2007 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,9 +22,9 @@ import org.springframework.batch.core.UnexpectedJobExecutionException;
* in the framework in case a skip sends itself into an infinite loop.
*
* @author Dave Syer
* @author Mahmoud Ben Hassine
*
*/
@SuppressWarnings("serial")
public class SkipPolicyFailedException extends UnexpectedJobExecutionException {
/**

View File

@@ -72,7 +72,6 @@ import java.util.concurrent.Semaphore;
* @author Will Schipp
* @author Mahmoud Ben Hassine
*/
@SuppressWarnings("serial")
public class TaskletStep extends AbstractStep {
private static final Log logger = LogFactory.getLog(TaskletStep.class);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2014 the original author or authors.
* Copyright 2014-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.
@@ -20,9 +20,9 @@ package org.springframework.batch.core.step.tasklet;
* extracted afterwards.
*
* @author Dave Syer
* @author Mahmoud Ben Hassine
*
*/
@SuppressWarnings("serial")
public class UncheckedTransactionException extends RuntimeException {
public UncheckedTransactionException(Exception e) {

View File

@@ -36,7 +36,6 @@ import org.springframework.lang.Nullable;
* @author Douglas Kaminsky
* @author Mahmoud Ben Hassine
*/
@SuppressWarnings("serial")
public class ExecutionContext implements Serializable {
private volatile boolean dirty = false;
@@ -340,13 +339,12 @@ public class ExecutionContext implements Serializable {
*/
@Override
public boolean equals(Object obj) {
if (obj instanceof ExecutionContext == false) {
if (!(obj instanceof ExecutionContext rhs)) {
return false;
}
if (this == obj) {
return true;
}
ExecutionContext rhs = (ExecutionContext) obj;
return this.entrySet().equals(rhs.entrySet());
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2007 the original author or authors.
* Copyright 2002-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.
@@ -20,8 +20,8 @@ package org.springframework.batch.item;
* A base exception class that all exceptions thrown from an {@link ItemReader} extend.
*
* @author Ben Hale
* @author Mahmoud Ben Hassine
*/
@SuppressWarnings("serial")
public abstract class ItemReaderException extends RuntimeException {
/**

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2007 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.
@@ -20,8 +20,8 @@ package org.springframework.batch.item;
*
* @author Dave Syer
* @author Lucas Ward
* @author Mahmoud Ben Hassine
*/
@SuppressWarnings("serial")
public class ItemStreamException extends RuntimeException {
/**

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2007 the original author or authors.
* Copyright 2002-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.
@@ -20,8 +20,8 @@ package org.springframework.batch.item;
* A base exception class that all exceptions thrown from an {@link ItemWriter} extend.
*
* @author Ben Hale
* @author Mahmoud Ben Hassine
*/
@SuppressWarnings("serial")
public abstract class ItemWriterException extends RuntimeException {
/**

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2007 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.
@@ -20,8 +20,8 @@ package org.springframework.batch.item;
* the exception should be considered fatal.
*
* @author Dave Syer
* @author Mahmoud Ben Hassine
*/
@SuppressWarnings("serial")
public class NonTransientResourceException extends ItemReaderException {
/**

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2007 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.
@@ -21,8 +21,8 @@ package org.springframework.batch.item;
*
* @author Lucas Ward
* @author Ben Hale
* @author Mahmoud Ben Hassine
*/
@SuppressWarnings("serial")
public class ParseException extends ItemReaderException {
/**

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2008 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.
@@ -19,8 +19,8 @@ package org.springframework.batch.item;
* Exception indicating that an {@link ItemReader} needed to be opened before read.
*
* @author Ben Hale
* @author Mahmoud Ben Hassine
*/
@SuppressWarnings("serial")
public class ReaderNotOpenException extends ItemReaderException {
/**

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2007 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 @@ package org.springframework.batch.item;
*
* @author Dave Syer
* @author Ben Hale
* @author Mahmoud Ben Hassine
*/
@SuppressWarnings("serial")
public class UnexpectedInputException extends ItemReaderException {
/**

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2008 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.
@@ -21,8 +21,8 @@ package org.springframework.batch.item;
*
* @author Lucas Ward
* @author Ben Hale
* @author Mahmoud Ben Hassine
*/
@SuppressWarnings("serial")
public class WriteFailedException extends ItemWriterException {
/**

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2008 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.
@@ -20,8 +20,8 @@ package org.springframework.batch.item;
* written to.
*
* @author Lucas Ward
* @author Mahmoud Ben Hassine
*/
@SuppressWarnings("serial")
public class WriterNotOpenException extends ItemWriterException {
/**

View File

@@ -68,7 +68,7 @@ public abstract class AbstractMethodInvokingDelegator<T> implements Initializing
*/
protected T invokeDelegateMethodWithArgument(Object object) throws Exception {
MethodInvoker invoker = createMethodInvoker(targetObject, targetMethod);
invoker.setArguments(new Object[] { object });
invoker.setArguments(object);
return doInvoke(invoker);
}
@@ -221,7 +221,6 @@ public abstract class AbstractMethodInvokingDelegator<T> implements Initializing
*
* @author Robert Kasanicky
*/
@SuppressWarnings("serial")
public static class InvocationTargetThrowableWrapper extends RuntimeException {
public InvocationTargetThrowableWrapper(Throwable cause) {

View File

@@ -117,7 +117,7 @@ public class RepositoryItemWriter<T> implements ItemWriter<T>, InitializingBean
MethodInvoker invoker = createMethodInvoker(repository, methodName);
for (T object : items) {
invoker.setArguments(new Object[] { object });
invoker.setArguments(object);
doInvoke(invoker);
}
}

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.
@@ -146,7 +146,7 @@ public class JdbcCursorItemReader<T> extends AbstractCursorItemReader<T> {
* @param connection to the database
*/
@Override
protected void cleanupOnClose(Connection connection) throws Exception {
protected void cleanupOnClose(Connection connection) {
JdbcUtils.closeStatement(this.preparedStatement);
JdbcUtils.closeConnection(connection);
}

View File

@@ -239,7 +239,7 @@ public class StoredProcedureItemReader<T> extends AbstractCursorItemReader<T> {
* @param connection to the database
*/
@Override
protected void cleanupOnClose(Connection connection) throws Exception {
protected void cleanupOnClose(Connection connection) {
JdbcUtils.closeStatement(this.callableStatement);
JdbcUtils.closeConnection(connection);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2007 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,12 +24,13 @@ import org.springframework.core.io.Resource;
/**
* @author Dave Syer
* @author Mahmoud Ben Hassine
* @since 2.1
*/
public class DefaultBufferedReaderFactory implements BufferedReaderFactory {
@Override
public BufferedReader create(Resource resource, String encoding) throws UnsupportedEncodingException, IOException {
public BufferedReader create(Resource resource, String encoding) throws IOException {
return new BufferedReader(new InputStreamReader(resource.getInputStream(), encoding));
}

View File

@@ -26,7 +26,6 @@ import org.springframework.batch.item.ParseException;
* @author Ben Hale
* @author Mahmoud Ben Hassine
*/
@SuppressWarnings("serial")
public class FlatFileParseException extends ParseException {
private final String input;

View File

@@ -23,7 +23,6 @@ import org.springframework.batch.item.NonTransientResourceException;
* @author Dave Syer
* @author Mahmoud Ben Hassine
*/
@SuppressWarnings("serial")
public class NonTransientFlatFileException extends NonTransientResourceException {
private final String input;

View File

@@ -74,7 +74,7 @@ public class SimpleBinaryBufferedReaderFactory implements BufferedReaderFactory
@Override
public String readLine() throws IOException {
StringBuilder buffer = null;
StringBuilder buffer;
synchronized (lock) {

View File

@@ -23,6 +23,7 @@ import org.springframework.util.StringUtils;
* they do not have unterminated quotes, and do not end in a continuation marker.
*
* @author Dave Syer
* @author Mahmoud Ben Hassine
*
*/
public class DefaultRecordSeparatorPolicy extends SimpleRecordSeparatorPolicy {
@@ -31,9 +32,9 @@ public class DefaultRecordSeparatorPolicy extends SimpleRecordSeparatorPolicy {
private static final String CONTINUATION = "\\";
private String quoteCharacter = QUOTE;
private String quoteCharacter;
private String continuation = CONTINUATION;
private String continuation;
/**
* Default constructor.

View File

@@ -162,9 +162,7 @@ public abstract class AbstractLineTokenizer implements LineTokenizer {
}
else {
// truncate token list to match the number of expected tokens
for (int i = tokensSize - 1; i >= nameLength; i--) {
tokens.remove(i);
}
tokens.subList(nameLength, tokensSize).clear();
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2007 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,9 +17,9 @@ package org.springframework.batch.item.file.transform;
/**
* @author Dave Syer
* @author Mahmoud Ben Hassine
*
*/
@SuppressWarnings("serial")
public class ConversionException extends RuntimeException {
/**

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2014 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.
@@ -21,9 +21,9 @@ package org.springframework.batch.item.file.transform;
*
* @author Lucas Ward
* @author Michael Minella
* @author Mahmoud Ben Hassine
*
*/
@SuppressWarnings("serial")
public class FlatFileFormatException extends RuntimeException {
private String input;

View File

@@ -23,7 +23,6 @@ package org.springframework.batch.item.file.transform;
* @author Mahmoud Ben Hassine
* @since 1.1
*/
@SuppressWarnings("serial")
public class IncorrectLineLengthException extends FlatFileFormatException {
private final int actualLength;

View File

@@ -24,7 +24,6 @@ package org.springframework.batch.item.file.transform;
* @author Mahmoud Ben Hassine
* @since 1.1
*/
@SuppressWarnings("serial")
public class IncorrectTokenCountException extends FlatFileFormatException {
private final int actualCount;

View File

@@ -586,7 +586,8 @@ public abstract class AbstractFileItemWriter<T> extends AbstractItemStreamItemWr
return writer;
}
else {
Writer writer = new BufferedWriter(Channels.newWriter(fileChannel, encoding)) {
return new BufferedWriter(Channels.newWriter(fileChannel, encoding)) {
@Override
public void flush() throws IOException {
super.flush();
@@ -595,8 +596,6 @@ public abstract class AbstractFileItemWriter<T> extends AbstractItemStreamItemWr
}
}
};
return writer;
}
}
catch (UnsupportedCharsetException ucse) {
@@ -612,7 +611,7 @@ public abstract class AbstractFileItemWriter<T> extends AbstractItemStreamItemWr
* @throws IOException if there is an IO problem
*/
private void checkFileSize() throws IOException {
long size = -1;
long size;
outputBufferedWriter.flush();
size = fileChannel.size();

View File

@@ -87,7 +87,7 @@ public abstract class AbstractItemCountingItemStreamItemReader<T> extends Abstra
@Nullable
@Override
public T read() throws Exception, UnexpectedInputException, ParseException {
public T read() throws Exception {
if (currentItemCount >= maxItemCount) {
return null;
}

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.
@@ -41,6 +41,7 @@ import org.springframework.lang.Nullable;
* </p>
*
* @author Dave Syer
* @author Mahmoud Ben Hassine
*
*/
public class SingleItemPeekableItemReader<T> implements ItemStreamReader<T>, PeekableItemReader<T> {
@@ -67,11 +68,10 @@ public class SingleItemPeekableItemReader<T> implements ItemStreamReader<T>, Pee
*/
@Nullable
@Override
public T read() throws Exception, UnexpectedInputException, ParseException {
public T read() throws Exception {
if (next != null) {
T item = next;
next = null;
// executionContext = new ExecutionContext();
return item;
}
return delegate.read();
@@ -86,7 +86,7 @@ public class SingleItemPeekableItemReader<T> implements ItemStreamReader<T>, Pee
*/
@Nullable
@Override
public T peek() throws Exception, UnexpectedInputException, ParseException {
public T peek() throws Exception {
if (next == null) {
updateDelegate(executionContext);
next = delegate.read();

View File

@@ -50,8 +50,7 @@ public class SynchronizedItemStreamReader<T> implements ItemStreamReader<T>, Ini
* This delegates to the read method of the <code>delegate</code>
*/
@Nullable
public synchronized T read()
throws Exception, UnexpectedInputException, ParseException, NonTransientResourceException {
public synchronized T read() throws Exception {
return this.delegate.read();
}

View File

@@ -39,9 +39,10 @@ public class BeanValidatingItemProcessor<T> extends ValidatingItemProcessor<T> {
* configuration.
*/
public BeanValidatingItemProcessor() {
LocalValidatorFactoryBean localValidatorFactoryBean = new LocalValidatorFactoryBean();
localValidatorFactoryBean.afterPropertiesSet();
this.validator = localValidatorFactoryBean.getValidator();
try (LocalValidatorFactoryBean localValidatorFactoryBean = new LocalValidatorFactoryBean()) {
localValidatorFactoryBean.afterPropertiesSet();
this.validator = localValidatorFactoryBean.getValidator();
}
}
/**

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2007 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,8 +22,8 @@ import org.springframework.batch.item.ItemReaderException;
* This exception should be thrown when there are validation errors.
*
* @author Ben Hale
* @author Mahmoud Ben Hassine
*/
@SuppressWarnings("serial")
public class ValidationException extends ItemReaderException {
/**

View File

@@ -259,7 +259,7 @@ public class StaxEventItemReader<T> extends AbstractItemCountingItemStreamItemRe
T item = null;
boolean success = false;
boolean success;
try {
success = moveCursorToNextFragment(fragmentReader);
}

View File

@@ -445,8 +445,8 @@ public class StaxEventItemWriter<T> extends AbstractItemStreamItemWriter<T>
private void open(long position) {
File file;
FileOutputStream os = null;
FileChannel fileChannel = null;
FileOutputStream os;
FileChannel fileChannel;
try {
file = resource.getFile();
@@ -479,9 +479,9 @@ public class StaxEventItemWriter<T> extends AbstractItemStreamItemWriter<T>
}
try {
final FileChannel channel = fileChannel;
if (transactional) {
TransactionAwareBufferedWriter writer = new TransactionAwareBufferedWriter(channel, this::closeStream);
TransactionAwareBufferedWriter writer = new TransactionAwareBufferedWriter(fileChannel,
this::closeStream);
writer.setEncoding(encoding);
writer.setForceSync(forceSync);
@@ -496,7 +496,7 @@ public class StaxEventItemWriter<T> extends AbstractItemStreamItemWriter<T>
if (!restarted) {
startDocument(delegateEventWriter);
if (forceSync) {
channel.force(false);
fileChannel.force(false);
}
}
}
@@ -539,8 +539,7 @@ public class StaxEventItemWriter<T> extends AbstractItemStreamItemWriter<T>
* loaded.
*/
protected XMLEventFactory createXmlEventFactory() throws FactoryConfigurationError {
XMLEventFactory factory = XMLEventFactory.newInstance();
return factory;
return XMLEventFactory.newInstance();
}
/**

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.
@@ -34,6 +34,7 @@ import org.springframework.batch.item.ItemStreamException;
* Default implementation of {@link FragmentEventReader}
*
* @author Robert Kasanicky
* @author Mahmoud Ben Hassine
*/
public class DefaultFragmentEventReader extends AbstractEventReaderWrapper implements FragmentEventReader {
@@ -49,9 +50,9 @@ public class DefaultFragmentEventReader extends AbstractEventReaderWrapper imple
// true when reader should behave like the cursor was at the end of document
private boolean fakeDocumentEnd = false;
private StartDocument startDocumentEvent = null;
private final StartDocument startDocumentEvent;
private EndDocument endDocumentEvent = null;
private final EndDocument endDocumentEvent;
// fragment root name is remembered so that the matching closing element can
// be identified

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2010 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.
@@ -28,6 +28,7 @@ import java.util.concurrent.TimeoutException;
* background thread to do the polling).
*
* @author Dave Syer
* @author Mahmoud Ben Hassine
* @param <S> the type of the result
*/
public class DirectPoller<S> implements Poller<S> {
@@ -93,7 +94,7 @@ public class DirectPoller<S> implements Poller<S> {
throw new ExecutionException(e);
}
Long nextExecutionTime = startTime + interval;
long nextExecutionTime = startTime + interval;
long currentTimeMillis = System.currentTimeMillis();
long timeoutMillis = TimeUnit.MILLISECONDS.convert(timeout, unit);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2007 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.
@@ -18,7 +18,6 @@ package org.springframework.batch.repeat;
import org.springframework.core.NestedRuntimeException;
@SuppressWarnings("serial")
public class RepeatException extends NestedRuntimeException {
public RepeatException(String msg) {

View File

@@ -132,7 +132,6 @@ public class RepeatOperationsInterceptor implements MethodInterceptor {
* @author Dave Syer
*
*/
@SuppressWarnings("serial")
private static class RepeatOperationsInterceptorException extends RepeatException {
public RepeatOperationsInterceptorException(String message, Throwable e) {

View File

@@ -64,7 +64,7 @@ public class DefaultPropertyEditorRegistrar implements PropertyEditorRegistrar {
this.customEditors = new HashMap<>();
for (Entry<?, ? extends PropertyEditor> entry : customEditors.entrySet()) {
Object key = entry.getKey();
Class<?> requiredType = null;
Class<?> requiredType;
if (key instanceof Class<?>) {
requiredType = (Class<?>) key;
}

View File

@@ -33,6 +33,7 @@ import org.springframework.util.ReflectionUtils;
* Utility methods for create MethodInvoker instances.
*
* @author Lucas Ward
* @author Mahmoud Ben Hassine
* @since 2.0
*/
public class MethodInvokerUtils {
@@ -179,11 +180,9 @@ public class MethodInvokerUtils {
/**
* Create a {@link MethodInvoker} for the delegate from a single public method.
* @param target an object to search for an appropriate method.
* @param <C> the class.
* @param <T> the type.
* @return a {@link MethodInvoker} that calls a method on the delegate.
*/
public static <C, T> MethodInvoker getMethodInvokerForSingleArgument(Object target) {
public static MethodInvoker getMethodInvokerForSingleArgument(Object target) {
final AtomicReference<Method> methodHolder = new AtomicReference<>();
ReflectionUtils.doWithMethods(target.getClass(), method -> {
if (method.getParameterTypes() == null || method.getParameterTypes().length != 1) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2008 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.
@@ -21,8 +21,8 @@ package org.springframework.batch.support.transaction;
*
* @author Lucas Ward
* @author Ben Hale
* @author Mahmoud Ben Hassine
*/
@SuppressWarnings("serial")
public class FlushFailedException extends RuntimeException {
/**

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2007 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,7 +25,6 @@ import org.springframework.transaction.support.AbstractPlatformTransactionManage
import org.springframework.transaction.support.DefaultTransactionStatus;
import org.springframework.transaction.support.TransactionSynchronizationManager;
@SuppressWarnings("serial")
public class ResourcelessTransactionManager extends AbstractPlatformTransactionManager {
@Override

Some files were not shown because too many files have changed in this diff Show More