Spring Batch
  1. Spring Batch
  2. BATCH-1529

Explicit protection against exceptions in SkipPolicy to prevent infinite loop in RetryTemplate

    Details

    • Type: New Feature New Feature
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 2.1.0
    • Fix Version/s: 2.1.1
    • Component/s: Core
    • Labels:
      None

      Description

      We use a RetryTemplate build using FaultTolerantFactoryBean. When an exception is thrown in one of our custom ErrorListener, the RetryTemplate decides that the exception is not fatal and retries. If that exception is consistently thrown by the ErrorListener the RetryTemplate will retry indefinitely and so an infinite loop will occur.

        Activity

        Hide
        Dave Syer added a comment -

        What is an ErrorListener (not part of Batch)? How did you install it or configure your step?

        Show
        Dave Syer added a comment - What is an ErrorListener (not part of Batch)? How did you install it or configure your step?
        Hide
        Nicolas Vanhoren added a comment -

        Yes, sorry, I get confused with all the helpers we made.
        The exception is thrown in the shouldSkip() method of a custom implementation of SkipPolicy which was simply given to the FaultTolerantStepFactoryBean. In our case, the SkipPolicy must update a status in database to indicate that the item(s) are in error or skipped. So it can sometimes throw exceptions (in case of problem with database communication,...).

        Show
        Nicolas Vanhoren added a comment - Yes, sorry, I get confused with all the helpers we made. The exception is thrown in the shouldSkip() method of a custom implementation of SkipPolicy which was simply given to the FaultTolerantStepFactoryBean. In our case, the SkipPolicy must update a status in database to indicate that the item(s) are in error or skipped. So it can sometimes throw exceptions (in case of problem with database communication,...).
        Hide
        Dave Syer added a comment -

        There is explicit protection in the framework for exceptions thrown by listeners (including skip listeners). Since you throw the exception in the SkipPolicy this won't apply. A workaround is to catch and wrap the exception in something fatal (e.g. RetryException).

        Show
        Dave Syer added a comment - There is explicit protection in the framework for exceptions thrown by listeners (including skip listeners). Since you throw the exception in the SkipPolicy this won't apply. A workaround is to catch and wrap the exception in something fatal (e.g. RetryException).

          People

          • Assignee:
            Dave Syer
            Reporter:
            Nicolas Vanhoren
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Time Tracking

              Estimated:
              Original Estimate - 0.25d Original Estimate - 0.25d
              0.25d
              Remaining:
              Time Spent - 0.25d Remaining Estimate - 0.25d
              0.25d
              Logged:
              Time Spent - 0.25d Remaining Estimate - 0.25d
              0.25d