title: SimpleAsyncTaskExecutor trying to read record after completion of processing
body: <p>In my spring batch project, I need to read from a list of rows from a table, create a chunk of 4 and process and then write to another table. I have implemented SimpleAsyncTaskExecutor to allow for parallel processing of chunks, but I find that after all records in the recordset are processed, Spring Batch is trying to continue reading next lot of result and failing. After it exceeds the skip level, it obviously aborts the job.</p>
  
  <p>My query is - why will be the batch continue to look for next record after completion of processing all records in the set? </p>
  
  <p>Error I get at the end is:</p>
  
  <blockquote>
    <p>org.springframework.batch.core.step.item.FaultTolerantChunkProvider -
    Skipping failed input
    org.springframework.jdbc.UncategorizedSQLException: Attempt to process
    next row failed; uncategorized SQLException for SQL</p>
  </blockquote>
  
  <p>Below is my batch xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;beans:beans xmlns="http://www.springframework.org/schema/batch"
      xmlns:beans="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:util="http://www.springframework.org/schema/util"
      xsi:schemaLocation="
          http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
          http://www.springframework.org/schema/batch http://www.springframework.org/schema/batch/spring-batch-2.1.xsd
          http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd"&gt;
  
      &lt;beans:import resource="../launch-context.xml" /&gt;
  
      &lt;beans:bean id="wsStudentItemReader"
          class="org.springframework.batch.item.database.JdbcCursorItemReader"    
          scope="step"&gt;
          &lt;beans:property name="dataSource" ref="rptDS" /&gt;
          &lt;beans:property name="sql"
              value="SELECT * FROM STUDENTS WHERE BATCH_ID=?" /&gt;
          &lt;beans:property name="preparedStatementSetter"&gt;
              &lt;beans:bean class="com.test.BatchDtSetter"
                  autowire="byName"&gt;
                  &lt;beans:property name="batchId" value="#{jobParameters[batchId]}" /&gt; 
              &lt;/beans:bean&gt;
          &lt;/beans:property&gt;
          &lt;beans:property name="rowMapper" ref="wsRowMapper" /&gt;
      &lt;/beans:bean&gt;
  
  
   &lt;beans:bean id="outputWriter"
          class="org.springframework.batch.item.support.ClassifierCompositeItemWriter"&gt;
          &lt;beans:property name="classifier" ref="writerClassifier" &gt;      
          &lt;/beans:property&gt;       
   &lt;/beans:bean&gt;  
  
  &lt;beans:bean id="writerClassifier"
      class="com.test.WriterClassifier"&gt;
      &lt;beans:property name="codeFailWriter" ref="failJdbcBatchItemWriter" /&gt;
      &lt;beans:property name="codePassWriter" ref="passJdbcBatchItemWriter"&gt;&lt;/beans:property&gt;
  &lt;/beans:bean&gt;
  
      &lt;beans:bean id="failJdbcBatchItemWriter"
          class="org.springframework.batch.item.database.JdbcBatchItemWriter"&gt;
          &lt;beans:property name="dataSource" ref="rptDS" /&gt;
          &lt;beans:property name="sql"
              value="DELETE FROM STUDENTS WHERE BATCH_ID=?" /&gt;
          &lt;beans:property name="itemPreparedStatementSetter" ref="FailStatusSetter" /&gt;
      &lt;/beans:bean&gt;
  
  &lt;beans:bean id="FailStatusSetter" class="com.test.FailStatusSetter" /&gt;
  
      &lt;beans:bean id="passJdbcBatchItemWriter"
          class="com.test.PassBatchItemWriter"&gt;
      &lt;/beans:bean&gt;
  
      &lt;beans:bean id="WSListnr"
          class="com.test.WSBatchListnr"&gt;
          &lt;beans:property name="dataSource" ref="rptDS" /&gt;
      &lt;/beans:bean&gt;
  
  
      &lt;beans:bean id="wsRowMapper" class="com.test.WSReqMapper" /&gt;
      &lt;beans:bean id="wsReqPrcsr" 
           class="com.test.WSReqProc"&gt;
           &lt;beans:property name="dataSource" ref="rptDS" /&gt;
      &lt;/beans:bean&gt;
      &lt;beans:bean id="wsReqPrepStmtSetter" class="com.test.wsStudentSetter" /&gt;
  
      &lt;step id="initiateStep"&gt;
          &lt;tasklet ref="initiateStepTask" /&gt;
      &lt;/step&gt;
      &lt;step id="wsStudentGenStep"&gt;
          &lt;tasklet task-executor="taskExecutor"&gt;
              &lt;chunk reader="wsStudentItemReader" processor="wsReqPrcsr"
                  writer="outputWriter" commit-interval="4" skip-limit="20"&gt;
                  &lt;skippable-exception-classes&gt;
                      &lt;include class="java.lang.Exception" /&gt;
                  &lt;/skippable-exception-classes&gt;
              &lt;/chunk&gt;
              &lt;listeners&gt; 
                  &lt;listener ref="WSListnr" /&gt;
              &lt;/listeners&gt;            
          &lt;/tasklet&gt;
      &lt;/step&gt;
      &lt;job id="wsStudent"&gt;
          &lt;step id="wsStudentFileGenIntialStep" parent="initiateStep"
              next="wsStudentFileGenStep" /&gt;
          &lt;step id="wsStudentFileGenStep" parent="wsStudentGenStep" /&gt;
      &lt;/job&gt;
  
  
      &lt;beans:bean id="initiateStepTask" class="com.test.Initializer"
          scope="step"&gt;
      &lt;/beans:bean&gt;
  
      &lt;beans:bean id="taskExecutor"
         class="org.springframework.core.task.SimpleAsyncTaskExecutor"&gt;
         &lt;beans:property name="concurrencyLimit" value="2"/&gt;
     &lt;/beans:bean&gt;
  
  &lt;/beans:beans&gt;
  </code></pre>