/** * Check if the exception is going to be retried, and veto the handling if * it is. If retry is exhausted or the exception is on the fatal list, then * handle using the delegate. * * @see ExceptionHandler#handleException(org.springframework.batch.repeat.RepeatContext, * java.lang.Throwable) */ @Override public void handleException(RepeatContext context, Throwable throwable) throws Throwable { // Only bother to check the delegate exception handler if we know that // retry is exhausted if (fatalExceptionClassifier.classify(throwable) || context.hasAttribute(EXHAUSTED)) { logger.debug("Handled fatal exception"); exceptionHandler.handleException(context, throwable); } else { logger.debug("Handled non-fatal exception", throwable); } }
/** * Construct a new {@link RepeatContextCounter}. * * @param context the current context. * @param countKey the key to use to store the counter in the context. * @param useParent true if the counter is to be shared between siblings. * The state will be stored in the parent of the context (if it exists) * instead of the context itself. */ public RepeatContextCounter(RepeatContext context, String countKey, boolean useParent) { super(); Assert.notNull(context, "The context must be provided to initialize a counter"); this.countKey = countKey; this.useParent = useParent; RepeatContext parent = context.getParent(); if (this.useParent && parent != null) { this.context = parent; } else { this.context = context; } if (!this.context.hasAttribute(countKey)) { this.context.setAttribute(countKey, new AtomicInteger()); } }
public void testAttributeCreatedInParent() throws Exception { new RepeatContextCounter(context, "FOO", true); assertFalse(context.hasAttribute("FOO")); assertTrue(parent.hasAttribute("FOO")); }
public void testAttributeCreated() { new RepeatContextCounter(context, "FOO"); assertTrue(context.hasAttribute("FOO")); }
public void testAttributeCreatedWithNullParent() { new RepeatContextCounter(parent, "FOO", true); assertTrue(parent.hasAttribute("FOO")); }
/** * Check if the exception is going to be retried, and veto the handling if * it is. If retry is exhausted or the exception is on the fatal list, then * handle using the delegate. * * @see ExceptionHandler#handleException(org.springframework.batch.repeat.RepeatContext, * java.lang.Throwable) */ public void handleException(RepeatContext context, Throwable throwable) throws Throwable { // Only bother to check the delegate exception handler if we know that // retry is exhausted if (fatalExceptionClassifier.classify(throwable) || context.hasAttribute(EXHAUSTED)) { logger.debug("Handled fatal exception"); exceptionHandler.handleException(context, throwable); } else { logger.debug("Handled non-fatal exception", throwable); } }
/** * Check if the exception is going to be retried, and veto the handling if * it is. If retry is exhausted or the exception is on the fatal list, then * handle using the delegate. * * @see ExceptionHandler#handleException(org.springframework.batch.repeat.RepeatContext, * java.lang.Throwable) */ @Override public void handleException(RepeatContext context, Throwable throwable) throws Throwable { // Only bother to check the delegate exception handler if we know that // retry is exhausted if (fatalExceptionClassifier.classify(throwable) || context.hasAttribute(EXHAUSTED)) { logger.debug("Handled fatal exception"); exceptionHandler.handleException(context, throwable); } else { logger.debug("Handled non-fatal exception", throwable); } }
/** * Check if the exception is going to be retried, and veto the handling if * it is. If retry is exhausted or the exception is on the fatal list, then * handle using the delegate. * * @see ExceptionHandler#handleException(org.springframework.batch.repeat.RepeatContext, * java.lang.Throwable) */ @Override public void handleException(RepeatContext context, Throwable throwable) throws Throwable { // Only bother to check the delegate exception handler if we know that // retry is exhausted if (fatalExceptionClassifier.classify(throwable) || context.hasAttribute(EXHAUSTED)) { logger.debug("Handled fatal exception"); exceptionHandler.handleException(context, throwable); } else { logger.debug("Handled non-fatal exception", throwable); } }
/** * Check if the exception is going to be retried, and veto the handling if * it is. If retry is exhausted or the exception is on the fatal list, then * handle using the delegate. * * @see ExceptionHandler#handleException(org.springframework.batch.repeat.RepeatContext, * java.lang.Throwable) */ @Override public void handleException(RepeatContext context, Throwable throwable) throws Throwable { // Only bother to check the delegate exception handler if we know that // retry is exhausted if (fatalExceptionClassifier.classify(throwable) || context.hasAttribute(EXHAUSTED)) { logger.debug("Handled fatal exception"); exceptionHandler.handleException(context, throwable); } else { logger.debug("Handled non-fatal exception", throwable); } }
/** * Construct a new {@link RepeatContextCounter}. * * @param context the current context. * @param countKey the key to use to store the counter in the context. * @param useParent true if the counter is to be shared between siblings. * The state will be stored in the parent of the context (if it exists) * instead of the context itself. */ public RepeatContextCounter(RepeatContext context, String countKey, boolean useParent) { super(); Assert.notNull(context, "The context must be provided to initialize a counter"); this.countKey = countKey; this.useParent = useParent; RepeatContext parent = context.getParent(); if (this.useParent && parent != null) { this.context = parent; } else { this.context = context; } if (!this.context.hasAttribute(countKey)) { this.context.setAttribute(countKey, new AtomicInteger()); } }