diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/partition/support/SimpleStepExecutionSplitter.java b/spring-batch-core/src/main/java/org/springframework/batch/core/partition/support/SimpleStepExecutionSplitter.java index 828f0176c..6f9cf20d7 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/partition/support/SimpleStepExecutionSplitter.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/partition/support/SimpleStepExecutionSplitter.java @@ -218,8 +218,7 @@ public class SimpleStepExecutionSplitter implements StepExecutionSplitter, Initi String stepName = stepExecution.getStepName(); StepExecution lastStepExecution = jobRepository.getLastStepExecution(jobInstance, stepName); - boolean isRestart = (lastStepExecution != null && lastStepExecution.getStatus() != BatchStatus.COMPLETED) ? true - : false; + boolean isRestart = (lastStepExecution != null && lastStepExecution.getStatus() != BatchStatus.COMPLETED); if (isRestart) { stepExecution.setExecutionContext(lastStepExecution.getExecutionContext()); diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/MapStepExecutionDao.java b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/MapStepExecutionDao.java index e160114d2..db3c581f0 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/MapStepExecutionDao.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/MapStepExecutionDao.java @@ -37,11 +37,9 @@ import org.springframework.util.ReflectionUtils; */ public class MapStepExecutionDao implements StepExecutionDao { - private Map> executionsByJobExecutionId = TransactionAwareProxyFactory - .createAppendOnlyTransactionalMap(); + private Map> executionsByJobExecutionId = TransactionAwareProxyFactory.createAppendOnlyTransactionalMap(); - private Map executionsByStepExecutionId = TransactionAwareProxyFactory - .createAppendOnlyTransactionalMap(); + private Map executionsByStepExecutionId = TransactionAwareProxyFactory.createAppendOnlyTransactionalMap(); private AtomicLong currentId = new AtomicLong(); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/TaskletStepTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/TaskletStepTests.java index 2d43c97c1..04576898f 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/TaskletStepTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/TaskletStepTests.java @@ -368,7 +368,7 @@ public class TaskletStepTests { step.execute(stepExecution); Throwable e = stepExecution.getFailureExceptions().get(0); - assertEquals("foo", e.getMessage()); + assertEquals("foo", e.getCause().getMessage()); assertEquals(BatchStatus.UNKNOWN, stepExecution.getStatus()); } diff --git a/spring-batch-core/src/test/resources/log4j.properties b/spring-batch-core/src/test/resources/log4j.properties index 0fa986064..c2b9d5503 100644 --- a/spring-batch-core/src/test/resources/log4j.properties +++ b/spring-batch-core/src/test/resources/log4j.properties @@ -7,6 +7,8 @@ log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %t %c{2} - %m%n log4j.category.org.apache.activemq=ERROR log4j.category.org.springframework.batch=DEBUG log4j.category.org.springframework.batch.support=INFO +log4j.category.org.springframework.batch.support.transaction.ResourcelessTransactionManager=DEBUG +log4j.category.org.springframework.core.repository=DEBUG # log4j.category.org.springframework.transaction=INFO log4j.category.org.springframework.jdbc=DEBUG diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/support/transaction/TransactionAwareProxyFactory.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/support/transaction/TransactionAwareProxyFactory.java index 9e78c7efd..ae31900dd 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/support/transaction/TransactionAwareProxyFactory.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/support/transaction/TransactionAwareProxyFactory.java @@ -168,11 +168,16 @@ public class TransactionAwareProxyFactory { if (appendOnly) { String methodName = invocation.getMethod().getName(); if ((result == null && methodName.equals("get")) - || (Boolean.FALSE.equals(result) && methodName.startsWith("contains"))) { + || (Boolean.FALSE.equals(result) && (methodName.startsWith("contains")) || (Boolean.TRUE.equals(result) && methodName.startsWith("isEmpty")))) { // In appendOnly mode the result of a get might not be // in the cache... return invocation.proceed(); } + if (result instanceof Collection) { + HashSet set = new HashSet((Collection) result); + set.addAll((Collection) invocation.proceed()); + result = set; + } } return result;