title: Spring Batch Job Infinite Loop
body: <p>I have found an strange issue with Java Spring Batch during the last minute of Production Release. It goes into infinite loop.</p>
  
  <p>Here is the config of mine:</p>
  
  <pre><code>&lt;batch:job id="dbasJob" restartable="true"&gt;       
      &lt;batch:step id="dbasStep" next="webService"&gt;         
          &lt;tasklet&gt;             
              &lt;chunk reader="campaignReader" processor="campaignProcessor" writer="campaignWriter" commit-interval="1" 
                  skip-limit="50"&gt;
  
                  &lt;skippable-exception-classes&gt;
                      &lt;include class="java.lang.Exception" /&gt;
                  &lt;/skippable-exception-classes&gt;
  
                  &lt;listeners&gt;
                      &lt;listener ref="campaignProcessListener" /&gt;
                      &lt;listener ref="campaignSkipListener" /&gt;
                  &lt;/listeners&gt;
              &lt;/chunk&gt;         
          &lt;/tasklet&gt;
          &lt;batch:listeners&gt;
              &lt;batch:listener ref="promotionListener" /&gt;
          &lt;/batch:listeners&gt;     
      &lt;/batch:step&gt;
  </code></pre>
  
  <p></p>
  
  <p>Total Number of records is 10. So the Commit happens after every single record is processed.
  I'm writing the results into database in the Writer.</p>
  
  <p>I'm fetching items one by one from the Reader, processing and writing to DB.</p>
  
  <pre><code>public Campaign read()
  {   
      return campaignList.isEmpty() ? null : campaignList.remove(0);
  }
  
  public Campaign process(Campaign campaign) throws UnexpectedInputException, ParseException, Exception {
  
      try 
  
  public void write(List&lt;? extends Campaign&gt; campaignList) throws Exception 
  {//...Writing to DB...
  </code></pre>
  
  <p>It keeps running and inserting data into the table infinitely.</p>
  
  <p>Observation is: Commit-Interval &lt; TotalRecords and Skip-Limit > Commit-Interval.</p>
  
  <p>If someone suggest some solution/workaround, would of greatest help to me at the point of time where Production release is held because of this issue.</p>
  
  <p>Thanks a lot.</p>