From 63496ee571519ea5c6c42c1baf52eba425575c0f Mon Sep 17 00:00:00 2001 From: robokaso Date: Wed, 27 Feb 2008 13:34:04 +0000 Subject: [PATCH] RESOLVED - issue BATCH-321: Throw exception if attempt to create duplicate job instance occurs (based on job parameters) http://jira.springframework.org/browse/BATCH-321 repository now throws exception if JobInstance already exists for non-restartable job. Had to tweak sample junit launcher to allow parameter setting because HibernateJob is run twice. --- .../repository/SimpleJobRepository.java | 39 ++++++++++--------- .../execution/launch/SimpleJobTests.java | 2 + .../SimpleJobRepositoryIntegrationTests.java | 22 +++++++++++ .../StepExecutorInterruptionTests.java | 7 +++- .../sample/AbstractBatchLauncherTests.java | 12 +++++- .../HibernateFailureJobFunctionalTests.java | 4 ++ 6 files changed, 64 insertions(+), 22 deletions(-) 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 86b27c026..d4e9c201a 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 @@ -87,10 +87,10 @@ public class SimpleJobRepository implements JobRepository { *

* There are two ways in which the method determines if a job should be * created or an existing one should be returned. The first is - * restartability. The {@link Job} restartable property will be - * checked first. If it is false, a new job will be created, regardless of - * whether or not one exists. If it is true, the {@link JobInstanceDao} will - * be checked to determine if the job already exists, if it does, it's steps + * restartability. The {@link Job} restartable property will be checked + * first. If it is false, a new job will be created, regardless of whether + * or not one exists. If it is true, the {@link JobInstanceDao} will be + * checked to determine if the job already exists, if it does, it's steps * will be populated (there must be at least 1) and a new * {@link JobExecution} will be returned. If no job instance is found, a new * one will be created. @@ -106,9 +106,9 @@ public class SimpleJobRepository implements JobRepository { *

  • What happens then depends on how many existing job instances we * find: *