BATCH-1620: fix bugs in TX aware proxy
This commit is contained in:
@@ -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());
|
||||
|
||||
@@ -37,11 +37,9 @@ import org.springframework.util.ReflectionUtils;
|
||||
*/
|
||||
public class MapStepExecutionDao implements StepExecutionDao {
|
||||
|
||||
private Map<Long, Map<Long, StepExecution>> executionsByJobExecutionId = TransactionAwareProxyFactory
|
||||
.createAppendOnlyTransactionalMap();
|
||||
private Map<Long, Map<Long, StepExecution>> executionsByJobExecutionId = TransactionAwareProxyFactory.createAppendOnlyTransactionalMap();
|
||||
|
||||
private Map<Long, StepExecution> executionsByStepExecutionId = TransactionAwareProxyFactory
|
||||
.createAppendOnlyTransactionalMap();
|
||||
private Map<Long, StepExecution> executionsByStepExecutionId = TransactionAwareProxyFactory.createAppendOnlyTransactionalMap();
|
||||
|
||||
private AtomicLong currentId = new AtomicLong();
|
||||
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -168,11 +168,16 @@ public class TransactionAwareProxyFactory<T> {
|
||||
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<Object> set = new HashSet<Object>((Collection<?>) result);
|
||||
set.addAll((Collection<?>) invocation.proceed());
|
||||
result = set;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
Reference in New Issue
Block a user