-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Open
Labels
status: waiting-for-triageIssues that we did not analyse yetIssues that we did not analyse yettype: bug
Description
I found a test case that breaks intermittently during working on #4755.
Lines 149 to 165 in 3bcc525
| @Test | |
| void testSimpleConcurrentJob() throws Exception { | |
| SimpleStepFactoryBean<String, String> factory = getStepFactory("foo", "bar"); | |
| factory.setTaskExecutor(new SimpleAsyncTaskExecutor()); | |
| AbstractStep step = (AbstractStep) factory.getObject(); | |
| step.setName("step1"); | |
| JobExecution jobExecution = repository.createJobExecution(job.getName(), new JobParameters()); | |
| StepExecution stepExecution = jobExecution.createStepExecution(step.getName()); | |
| repository.add(stepExecution); | |
| step.execute(stepExecution); | |
| assertEquals(BatchStatus.COMPLETED, stepExecution.getStatus()); | |
| assertEquals(2, written.size()); | |
| assertTrue(written.contains("foo")); | |
| } |
This test case wants to test concurrent job.
But, used Collections are not thread safe.
Lines 68 to 76 in 3bcc525
| private final List<Exception> listened = new ArrayList<>(); | |
| private JobRepository repository; | |
| private final List<String> written = new ArrayList<>(); | |
| private final ItemWriter<String> writer = data -> written.addAll(data.getItems()); | |
| private ItemReader<String> reader = new ListItemReader<>(Arrays.asList("a", "b", "c")); |
These collections should be thread safe.
Metadata
Metadata
Assignees
Labels
status: waiting-for-triageIssues that we did not analyse yetIssues that we did not analyse yettype: bug