Handle scenario where scanned item is filtered out
BATCH-2302 documents a scenario where an item throws an exception in a fault tollerant step in the write, then in the process, throws an exception as well. This leads to an infinite loop. To address this, prior to attempting to write items during scanning we need to validate that the there are items to be written (we were not which was causing a NoSuchElementException when we did inputs.next(). This commit also removes an eronous System.out left in the CoreNamespaceUtils.
This commit is contained in:
5
spring-batch-core/src/test/resources/data/person.csv
Normal file
5
spring-batch-core/src/test/resources/data/person.csv
Normal file
@@ -0,0 +1,5 @@
|
||||
Jill,Doe
|
||||
Joe,Doe
|
||||
Justin,Doe
|
||||
Jane,Doe
|
||||
John,Doe
|
||||
|
@@ -0,0 +1,47 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://www.springframework.org/schema/batch http://www.springframework.org/schema/batch/spring-batch.xsd">
|
||||
|
||||
<bean id="jobLauncher" class="org.springframework.batch.core.launch.support.SimpleJobLauncher">
|
||||
<property name="jobRepository" ref="jobRepository"/>
|
||||
</bean>
|
||||
|
||||
<bean id="reader" class="org.springframework.batch.item.file.FlatFileItemReader">
|
||||
<property name="resource" value="classpath:/data/person.csv"/>
|
||||
<property name="lineMapper">
|
||||
<bean class="org.springframework.batch.item.file.mapping.DefaultLineMapper">
|
||||
<property name="lineTokenizer">
|
||||
<bean class="org.springframework.batch.item.file.transform.DelimitedLineTokenizer">
|
||||
<property name="names" value="firstName,lastName"/>
|
||||
</bean>
|
||||
</property>
|
||||
<property name="fieldSetMapper">
|
||||
<bean class="org.springframework.batch.item.file.mapping.BeanWrapperFieldSetMapper">
|
||||
<property name="targetType" value="org.springframework.batch.core.step.skip.ReprocessExceptionTests$Person"/>
|
||||
</bean>
|
||||
</property>
|
||||
</bean>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="processor" class="org.springframework.batch.core.step.skip.ReprocessExceptionTests$PersonProcessor"/>
|
||||
|
||||
<bean id="writer" class="org.springframework.batch.core.step.skip.ReprocessExceptionTests$PersonItemWriter"/>
|
||||
|
||||
<job id="job" xmlns="http://www.springframework.org/schema/batch">
|
||||
<step id="step1">
|
||||
<tasklet>
|
||||
<chunk reader="reader" processor="processor" writer="writer" commit-interval="1">
|
||||
<skip-policy>
|
||||
<bean class="org.springframework.batch.core.step.skip.AlwaysSkipItemSkipPolicy" xmlns="http://www.springframework.org/schema/beans"/>
|
||||
</skip-policy>
|
||||
</chunk>
|
||||
</tasklet>
|
||||
</step>
|
||||
</job>
|
||||
|
||||
<bean id="jobRepository" class="org.springframework.batch.core.repository.support.MapJobRepositoryFactoryBean"/>
|
||||
<bean id="transactionManager" class="org.springframework.batch.support.transaction.ResourcelessTransactionManager"/>
|
||||
</beans>
|
||||
Reference in New Issue
Block a user