OPEN - issue BATCH-1522: Intermittent failure of FaultTolerantStepFactoryBean in multi-threaded test

This commit is contained in:
dsyer
2010-03-03 12:04:38 +00:00
parent 01697d9ffa
commit 9f37db9f39
5 changed files with 301 additions and 9 deletions

View File

@@ -30,10 +30,8 @@ import org.springframework.batch.core.StepExecution;
*/
public class ThreadStepInterruptionPolicy implements StepInterruptionPolicy {
protected static final Log logger = LogFactory
.getLog(ThreadStepInterruptionPolicy.class);
protected static final Log logger = LogFactory.getLog(ThreadStepInterruptionPolicy.class);
/**
* Returns if the current job lifecycle has been interrupted by checking if
* the current thread is interrupted.
@@ -43,7 +41,7 @@ public class ThreadStepInterruptionPolicy implements StepInterruptionPolicy {
if (isInterrupted(stepExecution)) {
throw new JobInterruptedException("Job interrupted status detected.");
}
}
/**
@@ -51,9 +49,15 @@ public class ThreadStepInterruptionPolicy implements StepInterruptionPolicy {
* @return true if the job has been interrupted
*/
private boolean isInterrupted(StepExecution stepExecution) {
boolean interrupted = (Thread.currentThread().isInterrupted() || stepExecution.isTerminateOnly());
if(interrupted){
logger.error("Step interrupted");
boolean interrupted = Thread.currentThread().isInterrupted();
if (interrupted) {
logger.info("Step interrupted through Thread API");
}
else {
interrupted = stepExecution.isTerminateOnly();
if (interrupted) {
logger.info("Step interrupted through StepExecution");
}
}
return interrupted;
}

View File

@@ -239,6 +239,11 @@ public class Chunk<W> implements Iterable<W> {
iterator.remove();
}
@Override
public String toString() {
return String.format("[items=%s, skips=%s]", items, skips);
}
}
}