Announcement Announcement Module
No announcement yet.
How to allow empty key list in DrivingQueryItemReader Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to allow empty key list in DrivingQueryItemReader


    How can I allow empty key lists in DrivingQueryItemReader? In Lucas Ward suggests that it can be done by using some kind of StepListener, but I have a hard time to figure out how. As far as I can tell, no matter what you do, the step/batch will be marked as failed anyway and the exception (NoWorkFoundException) will be rethrown.

    Help, please!

    Then I must also say that I disagree with the assumption that the step is a failure when there aren't any items to process. Nothing has been said about the number of items to expect to process. I've actually never come across a case where no items (left) to process means failure, but it's possible that they exist.


  • #2
    Someone else commented on this in Jira as well, the issue can be found here:

    I'd rather not duplicate it, so please read my last comment if you're curious about my reasoning for throwing a NoWorkFoundException. I'm still very much open for discussion (I'd like to think I'm always open for discussion), but I still feel pretty strongly about throwing the exception. Why can't you simply wrap the reader and catch the exception? This gives you the chance to log out the fact that no work was found. You can then return null and it will finish successfully? It seems like this gives you the opportunity to know that there was nothing found, without having to be stateful, while still allowing for others who would like a job to fail for this reason to have the exception thrown.