Announcement Announcement Module
No announcement yet.
How not to fail when input resource doesn't exist ? Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • How not to fail when input resource doesn't exist ?

    Hello !

    Something that's look quite simple doh

    When launching a job with any writer, an IllegalStateException is thrown and batch fails when specified input resource does not exist.

    So what would be the best appraoch for the batch to stop smartly and/or not to fail ?
    Last edited by tstebut; May 20th, 2008, 12:10 PM.

  • #2
    To keep a job from failing in the case of no input data, you would have to just swallow the exception.

    I'm not entirely sure what you mean by 'stop smartly' though


    • #3
      All right, I suppose I can catch this exception in onErrorInStep() (instanceOf) method of a StepExecutionListener and then return ExitStatus 0, but how do I abort the job then since there are some more steps remaining ?

      Furthermore, there could have been this kind of exception for other reasons...


      • #4
        If you throw an Exception and don't handle it until onErrorInStep, the step will be listed as failed as far as the framework is concerned, even if you modify the exit code.

        I'm not sure how to answer the second part. I understand your point though, since an IllegalStateException may also be thrown if a required dependency. However, from looking at the code, the only reason an IllegalStateException will be thrown from open is if the resource doesn't exist. If you wanted, you could wrap the reader so that the you could tell if the exception came from open. You could also handle this in your schedule as well. Create two jobs rather than one, and return a different exit code if the job finished with no file.