title: Spring Batch jobBuilderFactory with Flow 'on'
body: <p>Trying Spring Batch with Java based declaration instead for jobBuilderFactory and flow to direct condition step execution. I have a step execution listener at the end of the 'step2()' which returns a custom exit code which is used to pick the corresponding step after it. </p>
  
  <p>The unexpected behavior I am getting is that the job status ends up as 'FAILED' unless I explicitly define the on condition for the 'COMPLETED' ExitStatus ExitCode. The code seems to execute as expected otherwise. The cases are listed below. </p>
  
  <p>I see that the classes involved here are JobBuilder and FlowBuilder.</p>
  
  <p>Questions: </p>
  
  <p>1) Why do cases 2A and 2B result in job 'FAILED'? </p>
  
  <p>2) What is the XML equivalent of the below, if it helps clarify what is going on?</p>
  
  <pre><code>// 1. JOB STATUS ends up as COMPLETED
  jobBuilderFactory.get("myProcess")
  .flow(step1())
  .next(step2())
  .on(ExitStatus.COMPLETED.getExitCode())
  .end()
  .on("CUSTOM_EXIT_CODE")
  .to(step3())
  .end()
  .build();
  
  // 2A. JOB STATUS ends up as FAILED
  jobBuilderFactory.get("myProcess")
  .flow(step1())
  .next(step2())
  .on("CUSTOM_EXIT_CODE")
  .to(step3())
  .on(ExitStatus.COMPLETED.getExitCode())
  .end()
  .end()
  .build();
  
  // 2B. JOB STATUS ends up as FAILED
  jobBuilderFactory.get("myProcess")
  .flow(step1())
  .next(step2())
  .on("CUSTOM_EXIT_CODE")
  .to(step3())
  .end()
  .build();
  </code></pre>