RESOLVED - issue BATCH-782: Synchronization issue in ItemOrientedStep if exception is throw in chunk processing

Added flag to check that lock is not released before it is acquired
This commit is contained in:
dsyer
2008-08-14 12:35:05 +00:00
parent 69829b7da4
commit f29aa1e9fd
2 changed files with 60 additions and 18 deletions

View File

@@ -140,6 +140,36 @@ public class StepExecutorInterruptionTests extends TestCase {
}
public void testLockNotReleasedIfChunkFails() throws Exception {
step.setItemHandler(new SimpleStepHandler<Object>(new AbstractItemReader<Object>() {
public Object read() throws Exception {
throw new RuntimeException("Planned!");
}
}, itemWriter));
step.setSynchronizer(new StepExecutionSynchronizer() {
private boolean locked = false;
public void lock(StepExecution stepExecution) throws InterruptedException {
locked = true;
}
public void release(StepExecution stepExecution) {
assertTrue("Lock released before it is acquired", locked);
}
});
try {
step.execute(stepExecution);
fail("Expected planned RuntimeException");
} catch (RuntimeException e) {
assertEquals("Planned!", e.getMessage());
}
assertEquals(BatchStatus.FAILED, stepExecution.getStatus());
}
/**
* @return
*/