BATCH-1189: By default, all exceptions should be fatal
This commit is contained in:
@@ -27,6 +27,7 @@ import org.springframework.batch.item.ExecutionContext;
|
||||
import org.springframework.batch.item.ItemStreamException;
|
||||
import org.springframework.batch.item.ItemStreamSupport;
|
||||
import org.springframework.batch.item.ItemWriter;
|
||||
import org.springframework.batch.item.WriteFailedException;
|
||||
import org.springframework.batch.sample.domain.trade.Trade;
|
||||
import org.springframework.batch.sample.domain.trade.TradeDao;
|
||||
import org.springframework.util.Assert;
|
||||
@@ -58,7 +59,7 @@ public class TradeWriter extends ItemStreamSupport implements ItemWriter<Trade>
|
||||
Assert.notNull(trade.getPrice()); // There must be a price to total
|
||||
|
||||
if (this.failingCustomers.contains(trade.getCustomer())) {
|
||||
throw new RuntimeException("Something unexpected happened!");
|
||||
throw new WriteFailedException("Something unexpected happened!");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,11 @@
|
||||
processor="creditIncreaseProcessor"
|
||||
writer="hibernateCreditWriter"
|
||||
skip-limit="5"
|
||||
commit-interval="3"/>
|
||||
commit-interval="3">
|
||||
<skippable-exception-classes>
|
||||
java.lang.RuntimeException
|
||||
</skippable-exception-classes>
|
||||
</chunk>
|
||||
</tasklet>
|
||||
</step>
|
||||
</job>
|
||||
|
||||
@@ -17,6 +17,10 @@
|
||||
<tasklet>
|
||||
<chunk reader="fileItemReader" processor="tradeProcessor" writer="tradeWriter"
|
||||
commit-interval="3" skip-limit="10">
|
||||
<skippable-exception-classes>
|
||||
org.springframework.batch.item.file.FlatFileParseException
|
||||
org.springframework.batch.item.WriteFailedException
|
||||
</skippable-exception-classes>
|
||||
</chunk>
|
||||
</tasklet>
|
||||
|
||||
@@ -46,7 +50,7 @@
|
||||
<tasklet>
|
||||
<chunk writer="itemTrackingWriter">
|
||||
<skippable-exception-classes merge="true">
|
||||
java.lang.RuntimeException
|
||||
org.springframework.batch.item.validator.ValidationException
|
||||
</skippable-exception-classes>
|
||||
</chunk>
|
||||
</tasklet>
|
||||
@@ -59,7 +63,7 @@
|
||||
<chunk reader="tradeSqlItemReader" processor="tradeProcessor" writer="dummyWriter"
|
||||
commit-interval="2" skip-limit="10">
|
||||
<skippable-exception-classes>
|
||||
org.springframework.batch.item.validator.ValidationException
|
||||
java.lang.RuntimeException
|
||||
</skippable-exception-classes>
|
||||
</chunk>
|
||||
</tasklet>
|
||||
|
||||
Reference in New Issue
Block a user