Uploaded image for project: 'JBeret'
  1. JBeret
  2. JBERET-150

Use of a Decider which returns null with conditional flow control produces NullPointerException

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 1.1.0.Final
    • 1.1.0.Beta1
    • jberet-core
    • None

      decision element in job XML:

      <decision id="decide" ref="myDecider">
          <next on="goto-step0" to="step0"/>
          <next on="*" to="step2"/>
      </decision>
      

      Decider implementation:

      public class MyDecider implements Decider {
          @Override
          public String decide(StepExecution[] executions) throws Exception {
              System.out.println("MyDecider#decide(): returning null");
              return null;
          }
      }
      

      Exception:

      Mar 28, 2015 2:38:06 PM org.jberet.runtime.runner.CompositeExecutionRunner runDecision
      ERROR: JBERET000007: Failed to run job myjob, myDecider, app.MyDecider@1539d73d
      java.lang.NullPointerException
      	at org.jberet.runtime.runner.AbstractRunner.matches(AbstractRunner.java:61)
      	at org.jberet.runtime.runner.AbstractRunner.resolveTransitionElements(AbstractRunner.java:82)
      	at org.jberet.runtime.runner.CompositeExecutionRunner.runDecision(CompositeExecutionRunner.java:173)
      	at org.jberet.runtime.runner.CompositeExecutionRunner.runJobElement(CompositeExecutionRunner.java:134)
      	at org.jberet.runtime.runner.StepExecutionRunner.run(StepExecutionRunner.java:189)
      	at org.jberet.runtime.runner.CompositeExecutionRunner.runStep(CompositeExecutionRunner.java:164)
      	at org.jberet.runtime.runner.CompositeExecutionRunner.runFromHeadOrRestartPoint(CompositeExecutionRunner.java:88)
      	at org.jberet.runtime.runner.JobExecutionRunner.run(JobExecutionRunner.java:51)
      	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
      	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
      	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
      	at java.lang.Thread.run(Thread.java:745)
      

      I'm not sure how a Decider returns null should be treated by the JBatch runtime (may should fall back to the original exit status?), but I think NPE is not good anyway.

            cfang@redhat.com Cheng Fang
            xkylex Kohei Nozaki (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: