RESOLVED - issue BATCH-1301: ItemStream is not being opened correctly for multi-threaded Step when scope="step"

Fixed bug in unit test and tidied up context management
This commit is contained in:
dsyer
2009-06-21 08:52:47 +00:00
parent 528b5f6d9c
commit 1a92c5479a
2 changed files with 28 additions and 16 deletions

View File

@@ -78,14 +78,14 @@ public class AsyncStepScopeIntegrationTests implements BeanFactoryAware {
for (int i = 0; i < 12; i++) {
final String value = "foo" + i;
final Long id = 123L+i;
final Long id = 123L + i;
FutureTask<String> task = new FutureTask<String>(new Callable<String>() {
public String call() throws Exception {
StepExecution stepExecution = new StepExecution(value, new JobExecution(0L), id);
ExecutionContext executionContext = stepExecution.getExecutionContext();
executionContext.put("foo", value);
StepContext context = StepSynchronizationManager.register(stepExecution);
logger.debug("Registered: "+context.getStepExecutionContext());
logger.debug("Registered: " + context.getStepExecutionContext());
try {
return simple.getName();
}
@@ -117,13 +117,13 @@ public class AsyncStepScopeIntegrationTests implements BeanFactoryAware {
assertEquals("foo", simple.getName());
for (int i = 0; i < 12; i++) {
final String value = "foo"+i;
final String value = "foo" + i;
FutureTask<String> task = new FutureTask<String>(new Callable<String>() {
public String call() throws Exception {
ExecutionContext executionContext = stepExecution.getExecutionContext();
executionContext.put("foo", value);
StepContext context = StepSynchronizationManager.register(stepExecution);
logger.debug("Registered: "+context.getStepExecutionContext());
logger.debug("Registered: " + context.getStepExecutionContext());
try {
return simple.getName();
}
@@ -135,8 +135,6 @@ public class AsyncStepScopeIntegrationTests implements BeanFactoryAware {
tasks.add(task);
taskExecutor.execute(task);
}
StepSynchronizationManager.close();
int i = 0;
for (FutureTask<String> task : tasks) {
@@ -144,6 +142,10 @@ public class AsyncStepScopeIntegrationTests implements BeanFactoryAware {
i++;
}
// Don't close the outer scope until all tasks are finished. This should
// always be the case if using an AbstractStep
StepSynchronizationManager.close();
}
}