diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/domain/Job.java b/spring-batch-core/src/main/java/org/springframework/batch/core/domain/Job.java index dd94f8438..f2918f868 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/domain/Job.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/domain/Job.java @@ -17,7 +17,7 @@ package org.springframework.batch.core.domain; import java.util.List; -import org.springframework.batch.io.exception.BatchCriticalException; +import org.springframework.batch.io.exception.InfrastructureException; /** * Batch domain object representing a job. Job is an explicit abstraction @@ -43,8 +43,8 @@ public interface Job { * and statistics as necessary. * * @param execution a {@link JobExecution} - * @throws BatchCriticalException + * @throws InfrastructureException */ - void execute(JobExecution execution) throws BatchCriticalException; + void execute(JobExecution execution) throws InfrastructureException; } \ No newline at end of file diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/domain/JobInterruptedException.java b/spring-batch-core/src/main/java/org/springframework/batch/core/domain/JobInterruptedException.java index ab8afee72..112e8d6ba 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/domain/JobInterruptedException.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/domain/JobInterruptedException.java @@ -16,13 +16,13 @@ package org.springframework.batch.core.domain; -import org.springframework.batch.io.exception.BatchCriticalException; +import org.springframework.batch.io.exception.InfrastructureException; /** * Exception to indicate the the job has been interrupted. The exception state * indicated is not normally recoverable by batch application clients, but * internally it is useful to force a check. The exception will often be wrapped - * in a runtime exception (usually {@link BatchCriticalException} before + * in a runtime exception (usually {@link InfrastructureException} before * reaching the client. * * @author Lucas Ward diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/domain/Step.java b/spring-batch-core/src/main/java/org/springframework/batch/core/domain/Step.java index 6d1eb3f36..3c4a37099 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/domain/Step.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/domain/Step.java @@ -15,7 +15,7 @@ */ package org.springframework.batch.core.domain; -import org.springframework.batch.io.exception.BatchCriticalException; +import org.springframework.batch.io.exception.InfrastructureException; /** * Batch domain interface representing the configuration of a step. As with the @@ -57,9 +57,9 @@ public interface Step { * @param stepExecution an entity representing the step to be executed * * @throws JobInterruptedException if the step is interrupted externally - * @throws BatchCriticalException if there is a problem that needs to be + * @throws InfrastructureException if there is a problem that needs to be * signalled to the caller */ - void execute(StepExecution stepExecution) throws JobInterruptedException, BatchCriticalException; + void execute(StepExecution stepExecution) throws JobInterruptedException, InfrastructureException; } \ No newline at end of file diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/JobRepository.java b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/JobRepository.java index af8e01484..79b7ed19b 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/JobRepository.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/JobRepository.java @@ -61,10 +61,12 @@ public interface JobRepository { * @throws JobExecutionAlreadyRunningException if there is a * {@link JobExecution} alrady running for the job instance that would * otherwise be returned + * @throws JobRestartException if more than one JobInstance if found or if + * JobInstance.getJobExecutionCount() is greater than Job.getStartLimit() * */ public JobExecution createJobExecution(Job job, JobParameters jobParameters) - throws JobExecutionAlreadyRunningException; + throws JobExecutionAlreadyRunningException, JobRestartException; /** * Save or Update a {@link JobExecution}. If no ID is found a new instance diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/BatchRestartException.java b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/JobRestartException.java similarity index 74% rename from spring-batch-core/src/main/java/org/springframework/batch/core/repository/BatchRestartException.java rename to spring-batch-core/src/main/java/org/springframework/batch/core/repository/JobRestartException.java index 09e787b3d..60d03e2eb 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/BatchRestartException.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/JobRestartException.java @@ -15,18 +15,18 @@ */ package org.springframework.batch.core.repository; -import org.springframework.batch.io.exception.BatchCriticalException; - /** + * An exception indicating an illegal attempt to restart a job. + * * @author Dave Syer - * + * */ -public class BatchRestartException extends BatchCriticalException { +public class JobRestartException extends JobException { /** * @param string the message */ - public BatchRestartException(String string) { + public JobRestartException(String string) { super(string); } @@ -34,7 +34,7 @@ public class BatchRestartException extends BatchCriticalException { * @param msg the cause * @param t the message */ - public BatchRestartException(String msg, Throwable t) { + public JobRestartException(String msg, Throwable t) { super(msg, t); } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/domain/JobSupport.java b/spring-batch-core/src/test/java/org/springframework/batch/core/domain/JobSupport.java index 8e97ee695..f861eb58e 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/domain/JobSupport.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/domain/JobSupport.java @@ -22,7 +22,7 @@ import java.util.List; import org.springframework.batch.core.domain.Job; import org.springframework.batch.core.domain.JobExecution; import org.springframework.batch.core.domain.Step; -import org.springframework.batch.io.exception.BatchCriticalException; +import org.springframework.batch.io.exception.InfrastructureException; import org.springframework.beans.factory.BeanNameAware; import org.springframework.util.ClassUtils; @@ -136,7 +136,7 @@ public class JobSupport implements BeanNameAware, Job { /* (non-Javadoc) * @see org.springframework.batch.core.domain.Job#run(org.springframework.batch.core.domain.JobExecution) */ - public void execute(JobExecution execution) throws BatchCriticalException { + public void execute(JobExecution execution) throws InfrastructureException { throw new UnsupportedOperationException("JobSupport does not provide an implementation of run(). Use a smarter subclass."); } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/domain/StepSupport.java b/spring-batch-core/src/test/java/org/springframework/batch/core/domain/StepSupport.java index 91d831f07..4e41aaa03 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/domain/StepSupport.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/domain/StepSupport.java @@ -18,7 +18,7 @@ package org.springframework.batch.core.domain; import org.springframework.batch.core.domain.JobInterruptedException; import org.springframework.batch.core.domain.Step; import org.springframework.batch.core.domain.StepExecution; -import org.springframework.batch.io.exception.BatchCriticalException; +import org.springframework.batch.io.exception.InfrastructureException; import org.springframework.beans.factory.BeanNameAware; /** @@ -110,7 +110,7 @@ public class StepSupport implements Step, BeanNameAware { * * @see org.springframework.batch.core.domain.Step#execute(org.springframework.batch.core.domain.StepExecution) */ - public void execute(StepExecution stepExecution) throws JobInterruptedException, BatchCriticalException { + public void execute(StepExecution stepExecution) throws JobInterruptedException, InfrastructureException { throw new UnsupportedOperationException( "Cannot process a StepExecution. Use a smarter subclass of StepSupport."); } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/BatchRestartExceptionTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/JobRestartExceptionTests.java similarity index 85% rename from spring-batch-core/src/test/java/org/springframework/batch/core/repository/BatchRestartExceptionTests.java rename to spring-batch-core/src/test/java/org/springframework/batch/core/repository/JobRestartExceptionTests.java index bf309e29e..702c8333a 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/BatchRestartExceptionTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/JobRestartExceptionTests.java @@ -21,14 +21,14 @@ import org.springframework.batch.core.AbstractExceptionTests; * @author Dave Syer * */ -public class BatchRestartExceptionTests extends AbstractExceptionTests { +public class JobRestartExceptionTests extends AbstractExceptionTests { /* * (non-Javadoc) * @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String) */ public Exception getException(String msg) throws Exception { - return new BatchRestartException(msg); + return new JobRestartException(msg); } /* @@ -37,7 +37,7 @@ public class BatchRestartExceptionTests extends AbstractExceptionTests { * java.lang.Throwable) */ public Exception getException(String msg, Throwable t) throws Exception { - return new BatchRestartException(msg, t); + return new JobRestartException(msg, t); } } diff --git a/spring-batch-execution/src/main/java/org/springframework/batch/execution/bootstrap/SimpleExportedJobLauncher.java b/spring-batch-execution/src/main/java/org/springframework/batch/execution/bootstrap/SimpleExportedJobLauncher.java index 1de03f4ae..2ae497168 100644 --- a/spring-batch-execution/src/main/java/org/springframework/batch/execution/bootstrap/SimpleExportedJobLauncher.java +++ b/spring-batch-execution/src/main/java/org/springframework/batch/execution/bootstrap/SimpleExportedJobLauncher.java @@ -25,6 +25,7 @@ import org.springframework.batch.core.domain.Job; import org.springframework.batch.core.domain.JobExecution; import org.springframework.batch.core.domain.JobParameters; import org.springframework.batch.core.domain.StepExecution; +import org.springframework.batch.core.repository.JobRestartException; import org.springframework.batch.core.repository.JobExecutionAlreadyRunningException; import org.springframework.batch.core.repository.NoSuchJobException; import org.springframework.batch.core.runtime.JobParametersFactory; @@ -161,6 +162,9 @@ public class SimpleExportedJobLauncher implements ExportedJobLauncher, Initializ catch (JobExecutionAlreadyRunningException e) { return e.getClass().getName() + ": " + e.getMessage(); } + catch (JobRestartException e) { + return e.getClass().getName() + ": " + e.getMessage(); + } registry.put(name + params, execution); diff --git a/spring-batch-execution/src/main/java/org/springframework/batch/execution/job/SimpleJob.java b/spring-batch-execution/src/main/java/org/springframework/batch/execution/job/SimpleJob.java index 2a026861e..dc166dc80 100644 --- a/spring-batch-execution/src/main/java/org/springframework/batch/execution/job/SimpleJob.java +++ b/spring-batch-execution/src/main/java/org/springframework/batch/execution/job/SimpleJob.java @@ -32,7 +32,7 @@ import org.springframework.batch.core.repository.JobRepository; import org.springframework.batch.core.runtime.ExitStatusExceptionClassifier; import org.springframework.batch.execution.listener.CompositeJobListener; import org.springframework.batch.execution.step.support.SimpleExitStatusExceptionClassifier; -import org.springframework.batch.io.exception.BatchCriticalException; +import org.springframework.batch.io.exception.InfrastructureException; import org.springframework.batch.repeat.ExitStatus; /** @@ -63,7 +63,7 @@ public class SimpleJob extends AbstractJob { * * @see org.springframework.batch.core.domain.Job#execute(org.springframework.batch.core.domain.JobExecution) */ - public void execute(JobExecution execution) throws BatchCriticalException { + public void execute(JobExecution execution) throws InfrastructureException { JobInstance jobInstance = execution.getJobInstance(); jobInstance.setLastExecution(execution); @@ -158,7 +158,7 @@ public class SimpleJob extends AbstractJob { } if (stepStatus == BatchStatus.UNKNOWN) { - throw new BatchCriticalException("Cannot restart step from UNKNOWN status. " + throw new InfrastructureException("Cannot restart step from UNKNOWN status. " + "The last execution ended with a failure that could not be rolled back, " + "so it may be dangerous to proceed. " + "Manual intervention is probably necessary."); } @@ -175,7 +175,7 @@ public class SimpleJob extends AbstractJob { } else { // start max has been exceeded, throw an exception. - throw new BatchCriticalException("Maximum start limit exceeded for step: " + step.getName() + "StartMax: " + throw new InfrastructureException("Maximum start limit exceeded for step: " + step.getName() + "StartMax: " + step.getStartLimit()); } } @@ -188,7 +188,7 @@ public class SimpleJob extends AbstractJob { throw (RuntimeException) t; } else { - throw new BatchCriticalException(t); + throw new InfrastructureException(t); } } diff --git a/spring-batch-execution/src/main/java/org/springframework/batch/execution/launch/JobLauncher.java b/spring-batch-execution/src/main/java/org/springframework/batch/execution/launch/JobLauncher.java index a0c654758..734e5fd99 100644 --- a/spring-batch-execution/src/main/java/org/springframework/batch/execution/launch/JobLauncher.java +++ b/spring-batch-execution/src/main/java/org/springframework/batch/execution/launch/JobLauncher.java @@ -18,15 +18,16 @@ package org.springframework.batch.execution.launch; import org.springframework.batch.core.domain.Job; import org.springframework.batch.core.domain.JobExecution; import org.springframework.batch.core.domain.JobParameters; +import org.springframework.batch.core.repository.JobRestartException; import org.springframework.batch.core.repository.JobExecutionAlreadyRunningException; /** * Simple interface for controlling jobs, including possible ad-hoc executions, - * based on different runtime identifiers. It is extremely important to note - * that this interface makes absolutely no guarantees about whether or not - * calls to it are executed synchronously or asynchronously. The javadocs - * for specific implementations should be checked to ensure callers fully - * understand how the job will be run. + * based on different runtime identifiers. It is extremely important to note + * that this interface makes absolutely no guarantees about whether or not calls + * to it are executed synchronously or asynchronously. The javadocs for specific + * implementations should be checked to ensure callers fully understand how the + * job will be run. * * @author Lucas Ward * @author Dave Syer @@ -38,13 +39,16 @@ public interface JobLauncher { * Start a job execution for the given {@link Job} and {@link JobParameters}. * * @return the exit code from the job if it returns synchronously. If the - * implementation is asynchronous, the status might well be unknown. + * implementation is asynchronous, the status might well be unknown. * * @throws JobExecutionAlreadyRunningException if the JobInstance identified - * by the properties already has an execution running. Throws - * IllegalArgumentException if the job or jobInstanceProperties are null. + * by the properties already has an execution running. + * @throws IllegalArgumentException if the job or jobInstanceProperties are + * null. + * @throws JobRestartException if the job has been run before and + * circumstances that preclude a re-start. */ - public JobExecution run(Job job, JobParameters jobParameters) - throws JobExecutionAlreadyRunningException; + public JobExecution run(Job job, JobParameters jobParameters) throws JobExecutionAlreadyRunningException, + JobRestartException; } diff --git a/spring-batch-execution/src/main/java/org/springframework/batch/execution/launch/SimpleJobLauncher.java b/spring-batch-execution/src/main/java/org/springframework/batch/execution/launch/SimpleJobLauncher.java index 1e5669a80..f9bc960f5 100644 --- a/spring-batch-execution/src/main/java/org/springframework/batch/execution/launch/SimpleJobLauncher.java +++ b/spring-batch-execution/src/main/java/org/springframework/batch/execution/launch/SimpleJobLauncher.java @@ -21,6 +21,7 @@ import org.springframework.batch.core.domain.Job; import org.springframework.batch.core.domain.JobExecution; import org.springframework.batch.core.domain.JobInstance; import org.springframework.batch.core.domain.JobParameters; +import org.springframework.batch.core.repository.JobRestartException; import org.springframework.batch.core.repository.JobExecutionAlreadyRunningException; import org.springframework.batch.core.repository.JobRepository; import org.springframework.beans.factory.InitializingBean; @@ -30,8 +31,8 @@ import org.springframework.util.Assert; /** * Simple implementation of the {@link JobLauncher} interface. The Spring Core - * {@link TaskExecutor} interface is used to launch a {@link Job}. This - * means that the type of executor set is very important. If a + * {@link TaskExecutor} interface is used to launch a {@link Job}. This means + * that the type of executor set is very important. If a * {@link SyncTaskExecutor} is used, then the job will be processed * within the same thread that called the launcher. Care * should be taken to ensure any users of this class understand fully whether or @@ -40,9 +41,9 @@ import org.springframework.util.Assert; * * There is only one required dependency of this Launcher, a * {@link JobRepository}. The JobRepository is used to obtain a valid - * JobExecution. The Repository must be used because the provided - * {@link Job} could be a restart of an existing {@link JobInstance}, - * and only the Repository can reliably recreate it. + * JobExecution. The Repository must be used because the provided {@link Job} + * could be a restart of an existing {@link JobInstance}, and only the + * Repository can reliably recreate it. * * @author Lucas Ward * @since 1.0 @@ -67,9 +68,11 @@ public class SimpleJobLauncher implements JobLauncher, InitializingBean { * execution. * @return JobExecutionAlreadyRunningException if the JobInstance already * exists and has an execution already running. + * @throws JobRestartException if the execution would be a re-start, but a + * re-start is either not allowed or not needed. */ public JobExecution run(final Job job, final JobParameters jobParameters) - throws JobExecutionAlreadyRunningException { + throws JobExecutionAlreadyRunningException, JobRestartException { Assert.notNull(job, "The Job must not be null."); Assert.notNull(jobParameters, "The JobParameters must not be null."); diff --git a/spring-batch-execution/src/main/java/org/springframework/batch/execution/repository/SimpleJobRepository.java b/spring-batch-execution/src/main/java/org/springframework/batch/execution/repository/SimpleJobRepository.java index 27ad8ab33..7b5df7f23 100644 --- a/spring-batch-execution/src/main/java/org/springframework/batch/execution/repository/SimpleJobRepository.java +++ b/spring-batch-execution/src/main/java/org/springframework/batch/execution/repository/SimpleJobRepository.java @@ -26,7 +26,7 @@ import org.springframework.batch.core.domain.JobInstance; import org.springframework.batch.core.domain.JobParameters; import org.springframework.batch.core.domain.Step; import org.springframework.batch.core.domain.StepExecution; -import org.springframework.batch.core.repository.BatchRestartException; +import org.springframework.batch.core.repository.JobRestartException; import org.springframework.batch.core.repository.JobExecutionAlreadyRunningException; import org.springframework.batch.core.repository.JobRepository; import org.springframework.batch.execution.repository.dao.JobExecutionDao; @@ -132,15 +132,9 @@ public class SimpleJobRepository implements JobRepository { * * @see JobRepository#createJobExecution(Job, JobParameters) * - * @throws BatchRestartException if more than one JobInstance if found or if - * JobInstance.getJobExecutionCount() is greater than Job.getStartLimit() - * @throws JobExecutionAlreadyRunningException if a job execution is found - * for the given {@link JobIdentifier} that is already running - * @throws CannotRestartJobInstanceException - * */ public JobExecution createJobExecution(Job job, JobParameters jobParameters) - throws JobExecutionAlreadyRunningException { + throws JobExecutionAlreadyRunningException, JobRestartException { Assert.notNull(job, "Job must not be null."); Assert.notNull(jobParameters, "JobParameters must not be null."); @@ -161,12 +155,12 @@ public class SimpleJobRepository implements JobRepository { // existing job instance found if (jobInstance != null) { if (!job.isRestartable()) { - throw new BatchRestartException("JobInstance already exists and is not restartable"); + throw new JobRestartException("JobInstance already exists and is not restartable"); } jobInstance.setJobExecutionCount(jobExecutionDao.getJobExecutionCount(jobInstance)); if (jobInstance.getJobExecutionCount() > job.getStartLimit()) { - throw new BatchRestartException("Restart Max exceeded for Job: " + jobInstance.toString()); + throw new JobRestartException("Restart Max exceeded for Job: " + jobInstance.toString()); } List executions = jobExecutionDao.findJobExecutions(jobInstance); JobExecution lastExecution = null; diff --git a/spring-batch-execution/src/main/java/org/springframework/batch/execution/repository/dao/JdbcJobExecutionDao.java b/spring-batch-execution/src/main/java/org/springframework/batch/execution/repository/dao/JdbcJobExecutionDao.java index 4d72406ab..132f71a36 100644 --- a/spring-batch-execution/src/main/java/org/springframework/batch/execution/repository/dao/JdbcJobExecutionDao.java +++ b/spring-batch-execution/src/main/java/org/springframework/batch/execution/repository/dao/JdbcJobExecutionDao.java @@ -10,7 +10,6 @@ import org.apache.commons.logging.LogFactory; import org.springframework.batch.core.domain.BatchStatus; import org.springframework.batch.core.domain.JobExecution; import org.springframework.batch.core.domain.JobInstance; -import org.springframework.batch.core.repository.NoSuchBatchDomainObjectException; import org.springframework.batch.repeat.ExitStatus; import org.springframework.beans.factory.InitializingBean; import org.springframework.jdbc.core.RowMapper; @@ -147,7 +146,7 @@ public class JdbcJobExecutionDao extends AbstractJdbcBatchMetadataDao implements // is invalid and // an exception should be thrown. if (getJdbcTemplate().queryForInt(getQuery(CHECK_JOB_EXECUTION_EXISTS), new Object[] { jobExecution.getId() }) != 1) { - throw new NoSuchBatchDomainObjectException("Invalid JobExecution, ID " + jobExecution.getId() + throw new NoSuchObjectException("Invalid JobExecution, ID " + jobExecution.getId() + " not found."); } diff --git a/spring-batch-execution/src/main/java/org/springframework/batch/execution/repository/dao/JdbcStepExecutionDao.java b/spring-batch-execution/src/main/java/org/springframework/batch/execution/repository/dao/JdbcStepExecutionDao.java index 4addf3ab3..dfbafee35 100644 --- a/spring-batch-execution/src/main/java/org/springframework/batch/execution/repository/dao/JdbcStepExecutionDao.java +++ b/spring-batch-execution/src/main/java/org/springframework/batch/execution/repository/dao/JdbcStepExecutionDao.java @@ -16,7 +16,7 @@ import org.springframework.batch.core.domain.BatchStatus; import org.springframework.batch.core.domain.JobExecution; import org.springframework.batch.core.domain.Step; import org.springframework.batch.core.domain.StepExecution; -import org.springframework.batch.io.exception.BatchCriticalException; +import org.springframework.batch.io.exception.InfrastructureException; import org.springframework.batch.item.ExecutionContext; import org.springframework.batch.repeat.ExitStatus; import org.springframework.beans.factory.InitializingBean; @@ -108,7 +108,7 @@ public class JdbcStepExecutionDao extends AbstractJdbcBatchMetadataDao implement executionContext.put(key, rs.getObject("OBJECT_VAL")); } else { - throw new BatchCriticalException("Invalid type found: [" + typeCd + "] for execution id: [" + throw new InfrastructureException("Invalid type found: [" + typeCd + "] for execution id: [" + executionId + "]"); } } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/NoSuchBatchDomainObjectException.java b/spring-batch-execution/src/main/java/org/springframework/batch/execution/repository/dao/NoSuchObjectException.java similarity index 83% rename from spring-batch-core/src/main/java/org/springframework/batch/core/repository/NoSuchBatchDomainObjectException.java rename to spring-batch-execution/src/main/java/org/springframework/batch/execution/repository/dao/NoSuchObjectException.java index 12b65c91c..ccbdf1635 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/NoSuchBatchDomainObjectException.java +++ b/spring-batch-execution/src/main/java/org/springframework/batch/execution/repository/dao/NoSuchObjectException.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.batch.core.repository; +package org.springframework.batch.execution.repository.dao; /** * This exception identifies that a batch domain object is invalid, which @@ -24,11 +24,11 @@ package org.springframework.batch.core.repository; * @author Dave Syer * */ -public class NoSuchBatchDomainObjectException extends RuntimeException { +public class NoSuchObjectException extends RuntimeException { private static final long serialVersionUID = 4399621765157283111L; - public NoSuchBatchDomainObjectException(String message){ + public NoSuchObjectException(String message){ super(message); } } diff --git a/spring-batch-execution/src/main/java/org/springframework/batch/execution/step/AbstractStep.java b/spring-batch-execution/src/main/java/org/springframework/batch/execution/step/AbstractStep.java index 771011ee9..f5650fd4b 100644 --- a/spring-batch-execution/src/main/java/org/springframework/batch/execution/step/AbstractStep.java +++ b/spring-batch-execution/src/main/java/org/springframework/batch/execution/step/AbstractStep.java @@ -21,7 +21,7 @@ import org.springframework.batch.core.domain.Step; import org.springframework.batch.core.domain.StepExecution; import org.springframework.batch.core.repository.JobRepository; import org.springframework.batch.execution.step.support.NeverSkipItemSkipPolicy; -import org.springframework.batch.io.exception.BatchCriticalException; +import org.springframework.batch.io.exception.InfrastructureException; import org.springframework.batch.item.ItemReader; import org.springframework.batch.item.ItemWriter; import org.springframework.batch.repeat.exception.handler.ExceptionHandler; @@ -195,5 +195,5 @@ public abstract class AbstractStep implements Step, InitializingBean, BeanNameAw } - public abstract void execute(StepExecution stepExecution) throws JobInterruptedException, BatchCriticalException; + public abstract void execute(StepExecution stepExecution) throws JobInterruptedException, InfrastructureException; } \ No newline at end of file diff --git a/spring-batch-execution/src/main/java/org/springframework/batch/execution/step/ItemOrientedStep.java b/spring-batch-execution/src/main/java/org/springframework/batch/execution/step/ItemOrientedStep.java index b3437f508..c3e3a6a0a 100644 --- a/spring-batch-execution/src/main/java/org/springframework/batch/execution/step/ItemOrientedStep.java +++ b/spring-batch-execution/src/main/java/org/springframework/batch/execution/step/ItemOrientedStep.java @@ -33,7 +33,7 @@ import org.springframework.batch.execution.step.support.SimpleExitStatusExceptio import org.springframework.batch.execution.step.support.StepInterruptionPolicy; import org.springframework.batch.execution.step.support.ThreadStepInterruptionPolicy; import org.springframework.batch.io.Skippable; -import org.springframework.batch.io.exception.BatchCriticalException; +import org.springframework.batch.io.exception.InfrastructureException; import org.springframework.batch.item.ExecutionContext; import org.springframework.batch.item.ItemReader; import org.springframework.batch.item.ItemRecoverer; @@ -227,7 +227,7 @@ public class ItemOrientedStep extends AbstractStep implements InitializingBean { * execution * @see StepExecutor#execute(StepExecution) */ - public void execute(final StepExecution stepExecution) throws BatchCriticalException, JobInterruptedException { + public void execute(final StepExecution stepExecution) throws InfrastructureException, JobInterruptedException { JobInstance jobInstance = stepExecution.getJobExecution().getJobInstance(); StepExecution lastStepExecution = jobRepository.getLastStepExecution(jobInstance, this); @@ -418,7 +418,7 @@ public class ItemOrientedStep extends AbstractStep implements InitializingBean { if (!fatalException.hasException()) { fatalException.setException(e); } - throw new BatchCriticalException(msg, fatalException.getException()); + throw new InfrastructureException(msg, fatalException.getException()); } try { @@ -431,11 +431,11 @@ public class ItemOrientedStep extends AbstractStep implements InitializingBean { if (!fatalException.hasException()) { fatalException.setException(e); } - throw new BatchCriticalException(msg, fatalException.getException()); + throw new InfrastructureException(msg, fatalException.getException()); } if (fatalException.hasException()) { - throw new BatchCriticalException("Encountered an error saving batch meta data.", fatalException + throw new InfrastructureException("Encountered an error saving batch meta data.", fatalException .getException()); } diff --git a/spring-batch-execution/src/main/java/org/springframework/batch/execution/step/TaskletStep.java b/spring-batch-execution/src/main/java/org/springframework/batch/execution/step/TaskletStep.java index f9072be03..f29efdf74 100644 --- a/spring-batch-execution/src/main/java/org/springframework/batch/execution/step/TaskletStep.java +++ b/spring-batch-execution/src/main/java/org/springframework/batch/execution/step/TaskletStep.java @@ -27,7 +27,7 @@ import org.springframework.batch.core.domain.StepListener; import org.springframework.batch.core.repository.JobRepository; import org.springframework.batch.core.tasklet.Tasklet; import org.springframework.batch.execution.listener.CompositeStepListener; -import org.springframework.batch.io.exception.BatchCriticalException; +import org.springframework.batch.io.exception.InfrastructureException; import org.springframework.batch.repeat.ExitStatus; import org.springframework.beans.factory.BeanNameAware; import org.springframework.beans.factory.InitializingBean; @@ -191,7 +191,7 @@ public class TaskletStep implements Step, InitializingBean, BeanNameAware { this.jobRepository = jobRepository; } - public void execute(StepExecution stepExecution) throws JobInterruptedException, BatchCriticalException { + public void execute(StepExecution stepExecution) throws JobInterruptedException, InfrastructureException { stepExecution.setStartTime(new Date()); updateStatus(stepExecution, BatchStatus.STARTED); @@ -230,7 +230,7 @@ public class TaskletStep implements Step, InitializingBean, BeanNameAware { if (e instanceof RuntimeException) { throw (RuntimeException) e; } - throw new BatchCriticalException(e); + throw new InfrastructureException(e); } finally { stepExecution.setExitStatus(exitStatus); @@ -244,7 +244,7 @@ public class TaskletStep implements Step, InitializingBean, BeanNameAware { if (fatalException != null) { logger.error("Encountered an error saving batch meta data." + "This job is now in an unknown state and should not be restarted.", fatalException); - throw new BatchCriticalException("Encountered an error saving batch meta data.", fatalException); + throw new InfrastructureException("Encountered an error saving batch meta data.", fatalException); } } diff --git a/spring-batch-execution/src/main/java/org/springframework/batch/execution/step/support/SkipLimitExceededException.java b/spring-batch-execution/src/main/java/org/springframework/batch/execution/step/support/SkipLimitExceededException.java index 3891b9eaa..e5e6c61e4 100644 --- a/spring-batch-execution/src/main/java/org/springframework/batch/execution/step/support/SkipLimitExceededException.java +++ b/spring-batch-execution/src/main/java/org/springframework/batch/execution/step/support/SkipLimitExceededException.java @@ -15,7 +15,7 @@ */ package org.springframework.batch.execution.step.support; -import org.springframework.batch.io.exception.BatchCriticalException; +import org.springframework.batch.io.exception.InfrastructureException; /** * Exception indicating that the skip limit for a particular {@Step} has @@ -24,7 +24,7 @@ import org.springframework.batch.io.exception.BatchCriticalException; * @author Ben Hale * @author Lucas Ward */ -public class SkipLimitExceededException extends BatchCriticalException { +public class SkipLimitExceededException extends InfrastructureException { private final int skipLimit; diff --git a/spring-batch-execution/src/test/java/org/springframework/batch/execution/job/JobSupport.java b/spring-batch-execution/src/test/java/org/springframework/batch/execution/job/JobSupport.java index 3055617a7..3a20bce65 100644 --- a/spring-batch-execution/src/test/java/org/springframework/batch/execution/job/JobSupport.java +++ b/spring-batch-execution/src/test/java/org/springframework/batch/execution/job/JobSupport.java @@ -22,7 +22,7 @@ import java.util.List; import org.springframework.batch.core.domain.Job; import org.springframework.batch.core.domain.JobExecution; import org.springframework.batch.core.domain.Step; -import org.springframework.batch.io.exception.BatchCriticalException; +import org.springframework.batch.io.exception.InfrastructureException; import org.springframework.beans.factory.BeanNameAware; import org.springframework.util.ClassUtils; @@ -136,7 +136,7 @@ public class JobSupport implements BeanNameAware, Job { /* (non-Javadoc) * @see org.springframework.batch.core.domain.Job#run(org.springframework.batch.core.domain.JobExecution) */ - public void execute(JobExecution execution) throws BatchCriticalException { + public void execute(JobExecution execution) throws InfrastructureException { throw new UnsupportedOperationException("JobSupport does not provide an implementation of run(). Use a smarter subclass."); } diff --git a/spring-batch-execution/src/test/java/org/springframework/batch/execution/job/SimpleJobTests.java b/spring-batch-execution/src/test/java/org/springframework/batch/execution/job/SimpleJobTests.java index 6ce916ffb..c58ccacd8 100644 --- a/spring-batch-execution/src/test/java/org/springframework/batch/execution/job/SimpleJobTests.java +++ b/spring-batch-execution/src/test/java/org/springframework/batch/execution/job/SimpleJobTests.java @@ -39,7 +39,7 @@ import org.springframework.batch.execution.repository.dao.MapJobInstanceDao; import org.springframework.batch.execution.repository.dao.MapStepExecutionDao; import org.springframework.batch.execution.repository.dao.StepExecutionDao; import org.springframework.batch.execution.step.AbstractStep; -import org.springframework.batch.io.exception.BatchCriticalException; +import org.springframework.batch.io.exception.InfrastructureException; import org.springframework.batch.item.reader.AbstractItemReader; import org.springframework.batch.repeat.ExitStatus; @@ -193,7 +193,7 @@ public class SimpleJobTests extends TestCase { try { job.execute(jobExecution); } - catch (BatchCriticalException e) { + catch (InfrastructureException e) { assertEquals(exception, e.getCause()); } assertEquals(0, list.size()); @@ -223,7 +223,7 @@ public class SimpleJobTests extends TestCase { job.execute(jobExecution); fail("Expected BatchCriticalException"); } - catch (BatchCriticalException ex) { + catch (InfrastructureException ex) { // expected assertTrue("Wrong message in exception: " + ex.getMessage(), ex.getMessage() .indexOf("start limit exceeded") >= 0); @@ -255,7 +255,7 @@ public class SimpleJobTests extends TestCase { try { job.execute(jobExecution); } - catch (BatchCriticalException e) { + catch (InfrastructureException e) { assertTrue(e.getCause() instanceof JobInterruptedException); } assertEquals(0, list.size()); @@ -310,7 +310,7 @@ public class SimpleJobTests extends TestCase { this.runnable = runnable; } - public void execute(StepExecution stepExecution) throws JobInterruptedException, BatchCriticalException { + public void execute(StepExecution stepExecution) throws JobInterruptedException, InfrastructureException { if (exception instanceof RuntimeException) { throw (RuntimeException)exception; } diff --git a/spring-batch-execution/src/test/java/org/springframework/batch/execution/repository/SimpleJobRepositoryIntegrationTests.java b/spring-batch-execution/src/test/java/org/springframework/batch/execution/repository/SimpleJobRepositoryIntegrationTests.java index ae8461973..06fe2a3ed 100644 --- a/spring-batch-execution/src/test/java/org/springframework/batch/execution/repository/SimpleJobRepositoryIntegrationTests.java +++ b/spring-batch-execution/src/test/java/org/springframework/batch/execution/repository/SimpleJobRepositoryIntegrationTests.java @@ -6,7 +6,7 @@ import java.util.Map; import org.springframework.batch.core.domain.JobExecution; import org.springframework.batch.core.domain.JobParameters; -import org.springframework.batch.core.repository.BatchRestartException; +import org.springframework.batch.core.repository.JobRestartException; import org.springframework.batch.execution.job.JobSupport; import org.springframework.test.AbstractTransactionalDataSourceSpringContextTests; import org.springframework.util.ClassUtils; @@ -108,7 +108,7 @@ public class SimpleJobRepositoryIntegrationTests extends AbstractTransactionalDa jobRepository.createJobExecution(job, jobParameters); fail(); } - catch (BatchRestartException e) { + catch (JobRestartException e) { // expected } } diff --git a/spring-batch-execution/src/test/java/org/springframework/batch/execution/repository/SimpleJobRepositoryTests.java b/spring-batch-execution/src/test/java/org/springframework/batch/execution/repository/SimpleJobRepositoryTests.java index 29f602c9e..065b86981 100644 --- a/spring-batch-execution/src/test/java/org/springframework/batch/execution/repository/SimpleJobRepositoryTests.java +++ b/spring-batch-execution/src/test/java/org/springframework/batch/execution/repository/SimpleJobRepositoryTests.java @@ -28,7 +28,7 @@ import org.springframework.batch.core.domain.JobParameters; import org.springframework.batch.core.domain.JobParametersBuilder; import org.springframework.batch.core.domain.Step; import org.springframework.batch.core.domain.StepExecution; -import org.springframework.batch.core.repository.BatchRestartException; +import org.springframework.batch.core.repository.JobRestartException; import org.springframework.batch.execution.job.JobSupport; import org.springframework.batch.execution.repository.dao.JobExecutionDao; import org.springframework.batch.execution.repository.dao.JobInstanceDao; @@ -243,7 +243,7 @@ public class SimpleJobRepositoryTests extends TestCase { jobRepository.createJobExecution(jobConfiguration, jobParameters); fail(); } - catch (BatchRestartException ex) { + catch (JobRestartException ex) { // expected } diff --git a/spring-batch-execution/src/test/java/org/springframework/batch/execution/repository/dao/AbstractJobDaoTests.java b/spring-batch-execution/src/test/java/org/springframework/batch/execution/repository/dao/AbstractJobDaoTests.java index ee33ba4dc..914f71df0 100644 --- a/spring-batch-execution/src/test/java/org/springframework/batch/execution/repository/dao/AbstractJobDaoTests.java +++ b/spring-batch-execution/src/test/java/org/springframework/batch/execution/repository/dao/AbstractJobDaoTests.java @@ -26,7 +26,6 @@ import org.springframework.batch.core.domain.JobExecution; import org.springframework.batch.core.domain.JobInstance; import org.springframework.batch.core.domain.JobParameters; import org.springframework.batch.core.domain.JobParametersBuilder; -import org.springframework.batch.core.repository.NoSuchBatchDomainObjectException; import org.springframework.batch.execution.job.JobSupport; import org.springframework.batch.repeat.ExitStatus; import org.springframework.test.AbstractTransactionalDataSourceSpringContextTests; @@ -174,7 +173,7 @@ public abstract class AbstractJobDaoTests extends AbstractTransactionalDataSourc jobExecutionDao.updateJobExecution(execution); fail("Expected NoSuchBatchDomainObjectException"); } - catch (NoSuchBatchDomainObjectException ex) { + catch (NoSuchObjectException ex) { // expected } } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/NoSuchBatchDomainObjectExceptionTests.java b/spring-batch-execution/src/test/java/org/springframework/batch/execution/repository/dao/NoSuchBatchDomainObjectExceptionTests.java similarity index 78% rename from spring-batch-core/src/test/java/org/springframework/batch/core/repository/NoSuchBatchDomainObjectExceptionTests.java rename to spring-batch-execution/src/test/java/org/springframework/batch/execution/repository/dao/NoSuchBatchDomainObjectExceptionTests.java index 2056dd818..2386a2713 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/NoSuchBatchDomainObjectExceptionTests.java +++ b/spring-batch-execution/src/test/java/org/springframework/batch/execution/repository/dao/NoSuchBatchDomainObjectExceptionTests.java @@ -13,7 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.batch.core.repository; +package org.springframework.batch.execution.repository.dao; + +import org.springframework.batch.execution.repository.dao.NoSuchObjectException; import junit.framework.TestCase; @@ -24,7 +26,7 @@ import junit.framework.TestCase; public class NoSuchBatchDomainObjectExceptionTests extends TestCase { public void testCreateException() throws Exception { - NoSuchBatchDomainObjectException e = new NoSuchBatchDomainObjectException("Foo"); + NoSuchObjectException e = new NoSuchObjectException("Foo"); assertEquals("Foo", e.getMessage()); } } diff --git a/spring-batch-execution/src/test/java/org/springframework/batch/execution/step/ItemOrientedStepTests.java b/spring-batch-execution/src/test/java/org/springframework/batch/execution/step/ItemOrientedStepTests.java index 50907ea4c..ef0053217 100644 --- a/spring-batch-execution/src/test/java/org/springframework/batch/execution/step/ItemOrientedStepTests.java +++ b/spring-batch-execution/src/test/java/org/springframework/batch/execution/step/ItemOrientedStepTests.java @@ -39,7 +39,7 @@ import org.springframework.batch.execution.repository.dao.MapJobInstanceDao; import org.springframework.batch.execution.repository.dao.MapStepExecutionDao; import org.springframework.batch.execution.step.support.JobRepositorySupport; import org.springframework.batch.execution.step.support.StepInterruptionPolicy; -import org.springframework.batch.io.exception.BatchCriticalException; +import org.springframework.batch.io.exception.InfrastructureException; import org.springframework.batch.item.ExecutionContext; import org.springframework.batch.item.ItemReader; import org.springframework.batch.item.ItemWriter; @@ -255,7 +255,7 @@ public class ItemOrientedStepTests extends TestCase { itemOrientedStep.execute(stepExecution); fail("Expected BatchCriticalException"); } - catch (BatchCriticalException e) { + catch (InfrastructureException e) { assertEquals("foo", e.getCause().getMessage()); } assertEquals(BatchStatus.UNKNOWN, stepExecution.getStatus()); @@ -548,7 +548,7 @@ public class ItemOrientedStepTests extends TestCase { itemOrientedStep.execute(stepExecution); fail("Expected BatchCriticalException"); } - catch (BatchCriticalException ex) { + catch (InfrastructureException ex) { assertEquals(BatchStatus.UNKNOWN, stepExecution.getStatus()); String msg = stepExecution.getExitStatus().getExitDescription(); assertTrue("Message does not contain ResetFailedException: " + msg, msg.contains("ResetFailedException")); @@ -576,7 +576,7 @@ public class ItemOrientedStepTests extends TestCase { itemOrientedStep.execute(stepExecution); fail("Expected BatchCriticalException"); } - catch (BatchCriticalException ex) { + catch (InfrastructureException ex) { assertEquals(BatchStatus.UNKNOWN, stepExecution.getStatus()); String msg = stepExecution.getExitStatus().getExitDescription(); assertEquals("", msg); @@ -637,7 +637,7 @@ public class ItemOrientedStepTests extends TestCase { itemOrientedStep.execute(stepExecution); fail("Expected BatchCriticalException"); } - catch (BatchCriticalException ex) { + catch (InfrastructureException ex) { // The job actually completeed, but teh streams couldn't be closed. assertEquals(BatchStatus.COMPLETED, stepExecution.getStatus()); String msg = stepExecution.getExitStatus().getExitDescription(); diff --git a/spring-batch-execution/src/test/java/org/springframework/batch/execution/step/StepSupport.java b/spring-batch-execution/src/test/java/org/springframework/batch/execution/step/StepSupport.java index 74c6c9755..bdccb4df2 100644 --- a/spring-batch-execution/src/test/java/org/springframework/batch/execution/step/StepSupport.java +++ b/spring-batch-execution/src/test/java/org/springframework/batch/execution/step/StepSupport.java @@ -18,7 +18,7 @@ package org.springframework.batch.execution.step; import org.springframework.batch.core.domain.JobInterruptedException; import org.springframework.batch.core.domain.Step; import org.springframework.batch.core.domain.StepExecution; -import org.springframework.batch.io.exception.BatchCriticalException; +import org.springframework.batch.io.exception.InfrastructureException; import org.springframework.beans.factory.BeanNameAware; /** @@ -110,7 +110,7 @@ public class StepSupport implements Step, BeanNameAware { * * @see org.springframework.batch.core.domain.Step#execute(org.springframework.batch.core.domain.StepExecution) */ - public void execute(StepExecution stepExecution) throws JobInterruptedException, BatchCriticalException { + public void execute(StepExecution stepExecution) throws JobInterruptedException, InfrastructureException { throw new UnsupportedOperationException( "Cannot process a StepExecution. Use a smarter subclass of StepSupport."); } diff --git a/spring-batch-execution/src/test/java/org/springframework/batch/execution/step/TaskletStepTests.java b/spring-batch-execution/src/test/java/org/springframework/batch/execution/step/TaskletStepTests.java index 25b35f7d3..5652f08ac 100644 --- a/spring-batch-execution/src/test/java/org/springframework/batch/execution/step/TaskletStepTests.java +++ b/spring-batch-execution/src/test/java/org/springframework/batch/execution/step/TaskletStepTests.java @@ -15,7 +15,7 @@ import org.springframework.batch.core.listener.StepListenerSupport; import org.springframework.batch.core.tasklet.Tasklet; import org.springframework.batch.execution.job.JobSupport; import org.springframework.batch.execution.step.support.JobRepositorySupport; -import org.springframework.batch.io.exception.BatchCriticalException; +import org.springframework.batch.io.exception.InfrastructureException; import org.springframework.batch.repeat.ExitStatus; public class TaskletStepTests extends TestCase { @@ -89,7 +89,7 @@ public class TaskletStepTests extends TestCase { try { step.execute(stepExecution); fail("Expected BatchCriticalException"); - } catch (BatchCriticalException e){ + } catch (InfrastructureException e){ assertEquals("foo", e.getCause().getMessage()); } assertEquals(BatchStatus.UNKNOWN, stepExecution.getStatus()); @@ -118,7 +118,7 @@ public class TaskletStepTests extends TestCase { assertEquals(2, list.size()); } - public void testExceptionExecution() throws JobInterruptedException, BatchCriticalException { + public void testExceptionExecution() throws JobInterruptedException, InfrastructureException { TaskletStep step = new TaskletStep(new StubTasklet(false, true), new JobRepositorySupport()); try { step.execute(stepExecution); diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/exception/BatchEnvironmentException.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/exception/BatchEnvironmentException.java deleted file mode 100644 index 4c58aa328..000000000 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/exception/BatchEnvironmentException.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright 2006-2007 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.batch.io.exception; - -/** - * Exception that should be thrown to indicate an error in the environment. - * Excamples of such errors include file or database access errors. Because this - * class extends BatchCriticalException, throwing this error will indicate to - * the framework that processing should stop. It is vital that an error-code be - * passed as well, since this will be returned from the main method of the - * launcher. - * - * @author Lucas Ward - */ -public class BatchEnvironmentException extends BatchCriticalException { - private static final long serialVersionUID = 1382420837776529019L; - - /** - * Refer to the similar constructor in the parent class - * {@link BatchCriticalException}. - * - */ - public BatchEnvironmentException(String msg, Throwable nested) { - super(msg, nested); - } - - /** - * Refer to the similar constructor in the parent class - * {@link BatchCriticalException}. - * - */ - public BatchEnvironmentException(String msg) { - super(msg); - } - -} diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/exception/BatchConfigurationException.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/exception/ConfigurationException.java similarity index 81% rename from spring-batch-infrastructure/src/main/java/org/springframework/batch/io/exception/BatchConfigurationException.java rename to spring-batch-infrastructure/src/main/java/org/springframework/batch/io/exception/ConfigurationException.java index 7b90f0a92..d68344f41 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/exception/BatchConfigurationException.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/exception/ConfigurationException.java @@ -22,28 +22,28 @@ package org.springframework.batch.io.exception; * * @author Kerry O'Brien */ -public class BatchConfigurationException extends BatchCriticalException { +public class ConfigurationException extends InfrastructureException { private static final long serialVersionUID = 759498454063502984L; /** * @param msg * @param ex */ - public BatchConfigurationException(String msg, Throwable ex) { + public ConfigurationException(String msg, Throwable ex) { super(msg, ex); } /** * @param msg */ - public BatchConfigurationException(String msg) { + public ConfigurationException(String msg) { super(msg); } /** * @param nested */ - public BatchConfigurationException(Throwable nested) { + public ConfigurationException(Throwable nested) { super(nested); } } diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/exception/BatchCriticalException.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/exception/InfrastructureException.java similarity index 58% rename from spring-batch-infrastructure/src/main/java/org/springframework/batch/io/exception/BatchCriticalException.java rename to spring-batch-infrastructure/src/main/java/org/springframework/batch/io/exception/InfrastructureException.java index dfe78aa4f..4241e6e09 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/exception/BatchCriticalException.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/exception/InfrastructureException.java @@ -17,20 +17,13 @@ package org.springframework.batch.io.exception; /** - * BatchCritcalException - Indiates to the framework that a critical error has - * occured and batch processing should immeadiately stop. However, in most cases - * status should still be persisted indicating that an error foced the job to - * terminate. Any framework code that catches a BatchCriticalException will - * rethrow the exception. This allows any code that creates a critical exception - * to be able to add an error code that will still be accesible at the very - * beginning of the call chain. (usually a launcher that kicked off the - * JobController). Error code values 0 - 2000 a reserved for framework classes. - * Anything greater than 2000 can be used by application code. + * Indicates to the framework that a critical error has occurred and processing + * should immediately stop. * * @author Lucas Ward * */ -public class BatchCriticalException extends RuntimeException { +public class InfrastructureException extends RuntimeException { private static final long serialVersionUID = 8838982304219248527L; /** @@ -39,7 +32,7 @@ public class BatchCriticalException extends RuntimeException { * @param msg the exception message. * */ - public BatchCriticalException(String msg) { + public InfrastructureException(String msg) { super(msg); } @@ -49,7 +42,7 @@ public class BatchCriticalException extends RuntimeException { * @param msg the exception message. * */ - public BatchCriticalException(String msg, Throwable nested) { + public InfrastructureException(String msg, Throwable nested) { super(msg, nested); } @@ -57,7 +50,7 @@ public class BatchCriticalException extends RuntimeException { * Constructs a new instance with a nested exception. The error code is * defaulted to 1 and the message is empty. */ - public BatchCriticalException(Throwable nested) { + public InfrastructureException(Throwable nested) { super(nested); } @@ -65,7 +58,7 @@ public class BatchCriticalException extends RuntimeException { * Constructs a new instance, the error code is defaulted to one and the * message is empty. */ - public BatchCriticalException() { + public InfrastructureException() { super(); } diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/exception/ReadFailureException.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/exception/ReadFailureException.java index 88cacd442..bce06b5d8 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/exception/ReadFailureException.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/exception/ReadFailureException.java @@ -24,7 +24,7 @@ import org.springframework.batch.item.ItemReader; * * @author Lucas Ward */ -public class ReadFailureException extends BatchCriticalException { +public class ReadFailureException extends InfrastructureException { private static final long serialVersionUID = 4113323182216735223L; diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/exception/WriteFailureException.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/exception/WriteFailureException.java index 5387c02f4..ed462aa46 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/exception/WriteFailureException.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/exception/WriteFailureException.java @@ -25,7 +25,7 @@ import org.springframework.batch.item.ItemWriter; * * @author Lucas Ward */ -public class WriteFailureException extends BatchCriticalException { +public class WriteFailureException extends InfrastructureException { private static final long serialVersionUID = -1933213086873834098L; private final Object item; diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/file/FlatFileItemWriter.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/file/FlatFileItemWriter.java index 516c38d5c..f8ad6ae71 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/file/FlatFileItemWriter.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/file/FlatFileItemWriter.java @@ -25,8 +25,8 @@ import java.nio.channels.Channels; import java.nio.channels.FileChannel; import java.nio.charset.UnsupportedCharsetException; -import org.springframework.batch.io.exception.BatchCriticalException; -import org.springframework.batch.io.exception.BatchEnvironmentException; +import org.springframework.batch.io.exception.ConfigurationException; +import org.springframework.batch.io.exception.InfrastructureException; import org.springframework.batch.io.file.mapping.FieldSet; import org.springframework.batch.io.file.mapping.FieldSetCreator; import org.springframework.batch.io.file.transform.DelimitedLineAggregator; @@ -258,7 +258,7 @@ public class FlatFileItemWriter implements ItemWriter, ItemStream, pos = fileChannel.position(); } catch (IOException e) { - throw new BatchCriticalException("An Error occured while trying to get filechannel position", e); + throw new InfrastructureException("An Error occured while trying to get filechannel position", e); } return pos; @@ -308,7 +308,7 @@ public class FlatFileItemWriter implements ItemWriter, ItemStream, fileChannel.close(); } catch (IOException ioe) { - throw new BatchEnvironmentException("Unable to close the the ItemWriter", ioe); + throw new StreamException("Unable to close the the ItemWriter", ioe); } } @@ -328,7 +328,7 @@ public class FlatFileItemWriter implements ItemWriter, ItemStream, linesWritten++; } catch (IOException e) { - throw new BatchCriticalException("An Error occured while trying to write to FlatFileItemWriter", e); + throw new InfrastructureException("An Error occured while trying to write to FlatFileItemWriter", e); } } @@ -341,7 +341,7 @@ public class FlatFileItemWriter implements ItemWriter, ItemStream, fileChannel.position(lastMarkedByteOffsetPosition); } catch (IOException e) { - throw new BatchCriticalException("An Error occured while truncating output file", e); + throw new InfrastructureException("An Error occured while truncating output file", e); } } @@ -375,7 +375,7 @@ public class FlatFileItemWriter implements ItemWriter, ItemStream, file.delete(); } else { - throw new BatchEnvironmentException("Resource already exists: " + resource); + throw new StreamException("Resource already exists: " + resource); } } String parent = file.getParent(); @@ -395,7 +395,7 @@ public class FlatFileItemWriter implements ItemWriter, ItemStream, fileChannel = (new FileOutputStream(file.getAbsolutePath(), true)).getChannel(); } catch (FileNotFoundException fnfe) { - throw new BatchEnvironmentException("Bad filename property parameter " + file, fnfe); + throw new ConfigurationException("Bad filename property parameter " + file, fnfe); } outputBufferedWriter = getBufferedWriter(fileChannel, encoding, bufferSize); @@ -429,7 +429,7 @@ public class FlatFileItemWriter implements ItemWriter, ItemStream, return outputBufferedWriter; } catch (UnsupportedCharsetException ucse) { - throw new BatchEnvironmentException("Bad encoding configuration for output file " + fileChannel, ucse); + throw new StreamException("Bad encoding configuration for output file " + fileChannel, ucse); } } @@ -441,7 +441,7 @@ public class FlatFileItemWriter implements ItemWriter, ItemStream, * truncates the file to that reset position, and set the cursor to * start writing at that point. */ - public void reset() throws BatchCriticalException { + public void reset() throws InfrastructureException { checkFileSize(); getOutputState().truncate(); } @@ -460,11 +460,11 @@ public class FlatFileItemWriter implements ItemWriter, ItemStream, size = fileChannel.size(); } catch (IOException e) { - throw new BatchCriticalException("An Error occured while checking file size", e); + throw new InfrastructureException("An Error occured while checking file size", e); } if (size < lastMarkedByteOffsetPosition) { - throw new BatchCriticalException("Current file size is smaller than size at last commit"); + throw new InfrastructureException("Current file size is smaller than size at last commit"); } } @@ -474,7 +474,7 @@ public class FlatFileItemWriter implements ItemWriter, ItemStream, try { getOutputState().reset(); } - catch (BatchCriticalException e) { + catch (InfrastructureException e) { throw new ResetFailedException(e); } } diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/file/separator/ResourceLineReader.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/file/separator/ResourceLineReader.java index 4275f5740..082a6a0ea 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/file/separator/ResourceLineReader.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/file/separator/ResourceLineReader.java @@ -25,12 +25,12 @@ import java.util.Collections; import java.util.HashSet; import java.util.Iterator; -import org.springframework.batch.io.exception.BatchEnvironmentException; import org.springframework.batch.item.ExecutionContext; import org.springframework.batch.item.ItemReader; import org.springframework.batch.item.ItemStream; import org.springframework.batch.item.exception.MarkFailedException; import org.springframework.batch.item.exception.ResetFailedException; +import org.springframework.batch.item.exception.StreamException; import org.springframework.batch.item.stream.ItemStreamSupport; import org.springframework.core.io.Resource; import org.springframework.util.Assert; @@ -120,9 +120,6 @@ public class ResourceLineReader extends ItemStreamSupport implements LineReader, * * @return a String. * - * @throws BatchEnvironmentException if there is an IOException while - * accessing the input resource. - * * @see org.springframework.batch.item.reader.support.ItemReader#read() */ public synchronized Object read() { @@ -170,9 +167,7 @@ public class ResourceLineReader extends ItemStreamSupport implements LineReader, /** * Close the reader associated with this input source. * - * @see org.springframework.batch.io.ItemReader#close(ExecutionContext) - * @throws BatchEnvironmentException if there is an {@link IOException} - * during the close operation. + * @see org.springframework.batch.item.stream.ItemStreamSupport#close(org.springframework.batch.item.ExecutionContext) */ public synchronized void close(ExecutionContext executionContext) { if (state == null) { @@ -260,7 +255,7 @@ public class ResourceLineReader extends ItemStreamSupport implements LineReader, } } catch (IOException e) { - throw new BatchEnvironmentException("Unable to read from resource '" + resource + "' at line " + throw new StreamException("Unable to read from resource '" + resource + "' at line " + currentLineCount, e); } return line; @@ -275,7 +270,7 @@ public class ResourceLineReader extends ItemStreamSupport implements LineReader, mark(); } catch (IOException e) { - throw new BatchEnvironmentException("Could not open resource", e); + throw new StreamException("Could not open resource", e); } } @@ -291,7 +286,7 @@ public class ResourceLineReader extends ItemStreamSupport implements LineReader, reader.close(); } catch (IOException e) { - throw new BatchEnvironmentException("Could not close reader", e); + throw new StreamException("Could not close reader", e); } finally { currentLineCount = 0; diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/file/transform/DelimitedLineTokenizer.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/file/transform/DelimitedLineTokenizer.java index 3391d3793..5e41dd5b5 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/file/transform/DelimitedLineTokenizer.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/file/transform/DelimitedLineTokenizer.java @@ -19,7 +19,7 @@ package org.springframework.batch.io.file.transform; import java.util.ArrayList; import java.util.List; -import org.springframework.batch.io.exception.BatchConfigurationException; +import org.springframework.batch.io.exception.ConfigurationException; import org.springframework.util.StringUtils; /** @@ -70,7 +70,7 @@ public class DelimitedLineTokenizer extends AbstractLineTokenizer { */ public DelimitedLineTokenizer(char delimiter) { if (delimiter == DEFAULT_QUOTE_CHARACTER) { - throw new BatchConfigurationException("'" + DEFAULT_QUOTE_CHARACTER + throw new ConfigurationException("'" + DEFAULT_QUOTE_CHARACTER + "' is not allowed as delimiter for tokenizers."); } diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/exception/StreamException.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/exception/StreamException.java index b4d9e7417..071f66237 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/exception/StreamException.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/exception/StreamException.java @@ -15,7 +15,7 @@ */ package org.springframework.batch.item.exception; -import org.springframework.batch.io.exception.BatchCriticalException; +import org.springframework.batch.io.exception.InfrastructureException; /** * Exception representing any errors encountered while processing @@ -24,7 +24,7 @@ import org.springframework.batch.io.exception.BatchCriticalException; * @author Dave Syer * @author Lucas Ward */ -public class StreamException extends BatchCriticalException { +public class StreamException extends InfrastructureException { /** * @param message diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/io/exception/BatchEnvironmentExceptionTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/io/exception/BatchEnvironmentExceptionTests.java deleted file mode 100644 index 91b27aa10..000000000 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/io/exception/BatchEnvironmentExceptionTests.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2006-2007 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.batch.io.exception; - -import org.springframework.batch.io.exception.BatchCriticalException; -import org.springframework.batch.io.exception.BatchEnvironmentException; - -public class BatchEnvironmentExceptionTests extends AbstractExceptionTests { - - public Exception getException(String msg) throws Exception { - return new BatchEnvironmentException(msg); - } - - public Exception getException(Throwable t) throws Exception { - return new BatchCriticalException(t); - } - - public Exception getException(String msg, Throwable t) throws Exception { - return new BatchEnvironmentException(msg, t); - } - -} diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/io/exception/BatchConfigurationExceptionTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/io/exception/ConfigurationExceptionTests.java similarity index 75% rename from spring-batch-infrastructure/src/test/java/org/springframework/batch/io/exception/BatchConfigurationExceptionTests.java rename to spring-batch-infrastructure/src/test/java/org/springframework/batch/io/exception/ConfigurationExceptionTests.java index 641e652f4..b229c5cb6 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/io/exception/BatchConfigurationExceptionTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/io/exception/ConfigurationExceptionTests.java @@ -16,20 +16,20 @@ package org.springframework.batch.io.exception; -import org.springframework.batch.io.exception.BatchConfigurationException; +import org.springframework.batch.io.exception.ConfigurationException; -public class BatchConfigurationExceptionTests extends AbstractExceptionTests { +public class ConfigurationExceptionTests extends AbstractExceptionTests { public Exception getException(String msg) throws Exception { - return new BatchConfigurationException(msg); + return new ConfigurationException(msg); } public Exception getException(Throwable t) throws Exception { - return new BatchConfigurationException(t); + return new ConfigurationException(t); } public Exception getException(String msg, Throwable t) throws Exception { - return new BatchConfigurationException(msg, t); + return new ConfigurationException(msg, t); } } diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/io/exception/BatchCriticalExceptionTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/io/exception/InfrastructureExceptionTests.java similarity index 81% rename from spring-batch-infrastructure/src/test/java/org/springframework/batch/io/exception/BatchCriticalExceptionTests.java rename to spring-batch-infrastructure/src/test/java/org/springframework/batch/io/exception/InfrastructureExceptionTests.java index eb3392ef3..3c483a5ee 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/io/exception/BatchCriticalExceptionTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/io/exception/InfrastructureExceptionTests.java @@ -17,18 +17,18 @@ package org.springframework.batch.io.exception; -public class BatchCriticalExceptionTests extends AbstractExceptionTests { +public class InfrastructureExceptionTests extends AbstractExceptionTests { public Exception getException(String msg) throws Exception { - return new BatchCriticalException(msg); + return new InfrastructureException(msg); } public Exception getException(Throwable t) throws Exception { - return new BatchCriticalException(t); + return new InfrastructureException(t); } public Exception getException(String msg, Throwable t) throws Exception { - return new BatchCriticalException(msg, t); + return new InfrastructureException(msg, t); } } diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/io/file/FlatFileItemReaderBasicTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/io/file/FlatFileItemReaderBasicTests.java index cbdaca55b..99eb6b7c3 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/io/file/FlatFileItemReaderBasicTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/io/file/FlatFileItemReaderBasicTests.java @@ -21,7 +21,6 @@ import java.io.InputStream; import junit.framework.TestCase; -import org.springframework.batch.io.exception.BatchEnvironmentException; import org.springframework.batch.io.exception.FlatFileParsingException; import org.springframework.batch.io.file.mapping.DefaultFieldSet; import org.springframework.batch.io.file.mapping.FieldSet; @@ -211,7 +210,7 @@ public class FlatFileItemReaderBasicTests extends TestCase { itemReader.open(executionContext); fail("Expected BatchEnvironmentException"); } - catch (BatchEnvironmentException e) { + catch (StreamException e) { // expected assertEquals("foo", e.getCause().getMessage()); } diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/io/file/ResourceLineReaderTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/io/file/ResourceLineReaderTests.java index 0b696dfd8..8d31b2f51 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/io/file/ResourceLineReaderTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/io/file/ResourceLineReaderTests.java @@ -21,9 +21,9 @@ import java.io.InputStream; import junit.framework.TestCase; -import org.springframework.batch.io.exception.BatchEnvironmentException; import org.springframework.batch.io.file.separator.ResourceLineReader; import org.springframework.batch.io.file.separator.SuffixRecordSeparatorPolicy; +import org.springframework.batch.item.exception.StreamException; import org.springframework.core.io.ByteArrayResource; import org.springframework.core.io.InputStreamResource; import org.springframework.core.io.Resource; @@ -43,7 +43,7 @@ public class ResourceLineReaderTests extends TestCase { reader.read(); fail("Expected InputException"); } - catch (BatchEnvironmentException e) { + catch (StreamException e) { // expected assertTrue(e.getMessage().startsWith("Unable to read")); } diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/item/writer/OrderWriter.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/item/writer/OrderWriter.java index 5657888d2..4e3a3b8b8 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/item/writer/OrderWriter.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/item/writer/OrderWriter.java @@ -16,7 +16,7 @@ package org.springframework.batch.sample.item.writer; -import org.springframework.batch.io.exception.BatchCriticalException; +import org.springframework.batch.io.exception.InfrastructureException; import org.springframework.batch.item.writer.DelegatingItemWriter; import org.springframework.batch.sample.domain.Order; @@ -25,7 +25,7 @@ import org.springframework.batch.sample.domain.Order; public class OrderWriter extends DelegatingItemWriter { public Object doProcess(Object data) { if (!(data instanceof Order)) { - throw new BatchCriticalException("OrderProcessor can process only Order objects"); + throw new InfrastructureException("OrderProcessor can process only Order objects"); } return data; } diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/tasklet/ExceptionThrowingItemReaderProxy.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/tasklet/ExceptionThrowingItemReaderProxy.java index 68df66df9..84a6170a5 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/tasklet/ExceptionThrowingItemReaderProxy.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/tasklet/ExceptionThrowingItemReaderProxy.java @@ -17,7 +17,7 @@ package org.springframework.batch.sample.tasklet; -import org.springframework.batch.io.exception.BatchCriticalException; +import org.springframework.batch.io.exception.InfrastructureException; import org.springframework.batch.item.ItemReader; import org.springframework.batch.item.reader.DelegatingItemReader; @@ -49,7 +49,7 @@ public class ExceptionThrowingItemReaderProxy extends DelegatingItemReader { counter++; if (counter == throwExceptionOnRecordNumber) { - throw new BatchCriticalException("Planned failure on count="+counter); + throw new InfrastructureException("Planned failure on count="+counter); } return super.read(); diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/RestartFunctionalTests.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/RestartFunctionalTests.java index 2988a9773..b7e2e8a54 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/RestartFunctionalTests.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/RestartFunctionalTests.java @@ -17,7 +17,7 @@ package org.springframework.batch.sample; import org.springframework.batch.core.domain.JobParameters; -import org.springframework.batch.io.exception.BatchCriticalException; +import org.springframework.batch.io.exception.InfrastructureException; import org.springframework.jdbc.core.JdbcOperations; /** @@ -63,7 +63,7 @@ public class RestartFunctionalTests extends AbstractBatchLauncherTests { runJob(); fail("First run of the job is expected to fail."); } - catch (BatchCriticalException expected) { + catch (InfrastructureException expected) { //expected assertTrue("Not planned exception: "+expected.getMessage(), expected.getMessage().toLowerCase().indexOf("planned")>=0); } diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/dao/JdbcJobRepositoryTests.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/dao/JdbcJobRepositoryTests.java index c48005dd0..e8ed4ef7d 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/dao/JdbcJobRepositoryTests.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/dao/JdbcJobRepositoryTests.java @@ -161,7 +161,7 @@ public class JdbcJobRepositoryTests extends AbstractTransactionalDataSourceSprin jobIds.add(execution.getJobId()); } - private JobExecution doConcurrentStart() throws InterruptedException, JobExecutionAlreadyRunningException { + private JobExecution doConcurrentStart() throws Exception { new Thread(new Runnable() { public void run() { try { diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/item/writer/OrderWriterTests.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/item/writer/OrderWriterTests.java index fb5180fb4..6b1ed4982 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/item/writer/OrderWriterTests.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/item/writer/OrderWriterTests.java @@ -3,7 +3,7 @@ package org.springframework.batch.sample.item.writer; import junit.framework.TestCase; import org.easymock.MockControl; -import org.springframework.batch.io.exception.BatchCriticalException; +import org.springframework.batch.io.exception.InfrastructureException; import org.springframework.batch.item.ItemWriter; import org.springframework.batch.sample.domain.Order; import org.springframework.batch.sample.item.writer.OrderWriter; @@ -46,7 +46,7 @@ public class OrderWriterTests extends TestCase { try { processor.write(this); fail("Batch critical exception was expected"); - } catch (BatchCriticalException bce) { + } catch (InfrastructureException bce) { assertTrue(true); } writerControl.verify(); diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/tasklet/ExceptionThrowingItemReaderProxyTests.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/tasklet/ExceptionThrowingItemReaderProxyTests.java index 374909211..fb6ddab98 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/tasklet/ExceptionThrowingItemReaderProxyTests.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/tasklet/ExceptionThrowingItemReaderProxyTests.java @@ -4,7 +4,7 @@ import java.util.ArrayList; import junit.framework.TestCase; -import org.springframework.batch.io.exception.BatchCriticalException; +import org.springframework.batch.io.exception.InfrastructureException; import org.springframework.batch.item.reader.ListItemReader; import org.springframework.batch.repeat.context.RepeatContextSupport; import org.springframework.batch.repeat.synch.RepeatSynchronizationManager; @@ -40,7 +40,7 @@ public class ExceptionThrowingItemReaderProxyTests extends TestCase { try { itemReader.read(); assertTrue(i < ITER_COUNT); - } catch (BatchCriticalException bce) { + } catch (InfrastructureException bce) { assertEquals(ITER_COUNT,i); } } diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/tasklet/JobSupport.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/tasklet/JobSupport.java index a7b03ebf5..901c0becf 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/tasklet/JobSupport.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/tasklet/JobSupport.java @@ -22,7 +22,7 @@ import java.util.List; import org.springframework.batch.core.domain.Job; import org.springframework.batch.core.domain.JobExecution; import org.springframework.batch.core.domain.Step; -import org.springframework.batch.io.exception.BatchCriticalException; +import org.springframework.batch.io.exception.InfrastructureException; import org.springframework.beans.factory.BeanNameAware; import org.springframework.util.ClassUtils; @@ -136,7 +136,7 @@ public class JobSupport implements BeanNameAware, Job { /* (non-Javadoc) * @see org.springframework.batch.core.domain.Job#run(org.springframework.batch.core.domain.JobExecution) */ - public void execute(JobExecution execution) throws BatchCriticalException { + public void execute(JobExecution execution) throws InfrastructureException { throw new UnsupportedOperationException("JobSupport does not provide an implementation of run(). Use a smarter subclass."); } diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/tasklet/StepSupport.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/tasklet/StepSupport.java index eb8b9f9b2..c1c1abae4 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/tasklet/StepSupport.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/tasklet/StepSupport.java @@ -18,7 +18,7 @@ package org.springframework.batch.sample.tasklet; import org.springframework.batch.core.domain.JobInterruptedException; import org.springframework.batch.core.domain.Step; import org.springframework.batch.core.domain.StepExecution; -import org.springframework.batch.io.exception.BatchCriticalException; +import org.springframework.batch.io.exception.InfrastructureException; import org.springframework.beans.factory.BeanNameAware; /** @@ -110,7 +110,7 @@ public class StepSupport implements Step, BeanNameAware { * * @see org.springframework.batch.core.domain.Step#execute(org.springframework.batch.core.domain.StepExecution) */ - public void execute(StepExecution stepExecution) throws JobInterruptedException, BatchCriticalException { + public void execute(StepExecution stepExecution) throws JobInterruptedException, InfrastructureException { throw new UnsupportedOperationException( "Cannot process a StepExecution. Use a smarter subclass of StepSupport."); }