Incomplete - task 84: Fix samples
Fix rollback tests as well - exception handler too complicated
This commit is contained in:
@@ -195,8 +195,8 @@ public class ItemOrientedStep extends AbstractStep implements InitializingBean {
|
||||
((RepeatTemplate) chunkOperations).setCompletionPolicy(new SimpleCompletionPolicy(commitInterval));
|
||||
}
|
||||
|
||||
if (this.chunkOperations instanceof RepeatTemplate && exceptionHandler != null) {
|
||||
((RepeatTemplate) chunkOperations).setExceptionHandler(exceptionHandler);
|
||||
if (this.stepOperations instanceof RepeatTemplate && exceptionHandler != null) {
|
||||
((RepeatTemplate) stepOperations).setExceptionHandler(exceptionHandler);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -355,7 +355,7 @@ public class ItemOrientedStepTests extends TestCase {
|
||||
|
||||
public void testApplyConfigurationWithExceptionHandler() throws Exception {
|
||||
final List list = new ArrayList();
|
||||
itemOrientedStep.setChunkOperations(new RepeatTemplate() {
|
||||
itemOrientedStep.setStepOperations(new RepeatTemplate() {
|
||||
public void setExceptionHandler(ExceptionHandler exceptionHandler) {
|
||||
list.add(exceptionHandler);
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@ package org.springframework.batch.repeat.exception.handler;
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.springframework.batch.common.ExceptionClassifierSupport;
|
||||
import org.springframework.batch.io.exception.WriteFailureException;
|
||||
import org.springframework.batch.repeat.RepeatContext;
|
||||
|
||||
/**
|
||||
@@ -32,14 +31,13 @@ import org.springframework.batch.repeat.RepeatContext;
|
||||
public class SimpleLimitExceptionHandler implements ExceptionHandler {
|
||||
|
||||
/**
|
||||
* Name of exception classifier key for the
|
||||
* {@link WriteFailureException}.
|
||||
* Name of exception classifier key for the nominated exception type.
|
||||
*/
|
||||
private static final String TX_INVALID = "TX_INVALID";
|
||||
|
||||
private RethrowOnThresholdExceptionHandler delegate = new RethrowOnThresholdExceptionHandler();
|
||||
|
||||
private Class type = WriteFailureException.class;
|
||||
private Class type = Exception.class;
|
||||
|
||||
/**
|
||||
* Flag to indicate the the exception counters should be shared between
|
||||
@@ -102,7 +100,7 @@ public class SimpleLimitExceptionHandler implements ExceptionHandler {
|
||||
|
||||
/**
|
||||
* Setter for the Throwable type that this handler counts. Defaults to
|
||||
* {@link WriteFailureException}.
|
||||
* {@link Exception}.
|
||||
*
|
||||
* @param type
|
||||
*/
|
||||
|
||||
@@ -55,7 +55,7 @@ public class SimpleLimitExceptionHandlerTests extends TestCase {
|
||||
}
|
||||
|
||||
/**
|
||||
* Other than TransactionInvalidException should be rethrown, ignoring the
|
||||
* Other than nominated exception type should be rethrown, ignoring the
|
||||
* exception limit.
|
||||
*
|
||||
* @throws Exception
|
||||
@@ -65,6 +65,7 @@ public class SimpleLimitExceptionHandlerTests extends TestCase {
|
||||
|
||||
final int MORE_THAN_ZERO = 1;
|
||||
handler.setLimit(MORE_THAN_ZERO);
|
||||
handler.setType(IllegalArgumentException.class);
|
||||
|
||||
try {
|
||||
handler.handleException(new RepeatContextSupport(null), throwable);
|
||||
|
||||
@@ -34,16 +34,6 @@
|
||||
ref="hibernateOutputSource" />
|
||||
</bean>
|
||||
</property>
|
||||
<property name="stepOperations">
|
||||
<bean
|
||||
class="org.springframework.batch.repeat.support.RepeatTemplate">
|
||||
<property name="exceptionHandler">
|
||||
<bean
|
||||
class="org.springframework.batch.repeat.exception.handler.SimpleLimitExceptionHandler"
|
||||
p:limit="2" p:useParent="true" p:type="java.lang.Exception" />
|
||||
</property>
|
||||
</bean>
|
||||
</property>
|
||||
</bean>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
@@ -31,6 +31,11 @@
|
||||
</bean>
|
||||
</property>
|
||||
<property name="commitInterval" value="2" />
|
||||
<property name="exceptionHandler">
|
||||
<bean class="org.springframework.batch.repeat.exception.handler.SimpleLimitExceptionHandler">
|
||||
<property name="limit" value="0"/>
|
||||
</bean>
|
||||
</property>
|
||||
</bean>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
@@ -35,12 +35,6 @@
|
||||
ref="tradeValidator" />
|
||||
</bean>
|
||||
</property>
|
||||
<property name="itemSkipPolicy">
|
||||
<bean
|
||||
class="org.springframework.batch.execution.step.support.LimitCheckingItemSkipPolicy">
|
||||
<constructor-arg value="5"/>
|
||||
</bean>
|
||||
</property>
|
||||
<property name="itemWriter">
|
||||
<bean
|
||||
class="org.springframework.batch.sample.item.writer.TradeWriter"
|
||||
|
||||
Reference in New Issue
Block a user