Uploaded image for project: 'BatchEE'
  1. BatchEE
  2. BATCHEE-139

JPAPersistenceManagerService throws a Nullpointer in case an invalid execution id is passed to getJobExecution

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 0.5-incubating
    • 0.6
    • jbatch-core
    • None

    Description

      HI BatchEE-Team,

      I'm using the

      org.apache.batchee.container.services.persistenceJPAPersistenceManagerService

      to store BatchEE's meta data in SQL database. So far so good ..

       

      However, I've just figured out that the exception handling mechanism is not implemented properly, when I call the getJobExecution method of the JobOperator with an invalid execution id.

       

      getJobExecution(final long executionId) throws NoSuchJobExecutionException, JobSecurityException

      As you can see the method signature illustrates that I would get a NoSuchJobExecutionException, rather than a Nullpointer which I'm facing ..

      java.lang.NullPointerException
       at org.apache.batchee.container.services.persistence.JPAPersistenceManagerService.jobOperatorGetJobExecution(JPAPersistenceManagerService.java:422)
       at org.apache.batchee.container.impl.jobinstance.JobExecutionHelper.getPersistedJobOperatorJobExecution(JobExecutionHelper.java:224)
       at org.apache.batchee.container.services.kernel.DefaultBatchKernel.getJobExecution(DefaultBatchKernel.java:138)
       at org.apache.batchee.container.impl.JobOperatorImpl.getJobExecution(JobOperatorImpl.java:170)
       at org.apache.batchee.container.impl.JobOperatorImpl.getJobExecution(JobOperatorImpl.java:64)

      I've just checked the code and at least the implementation of jobOperatorGetJobExecution would need to be changed:

       

      @Override
       public InternalJobExecution jobOperatorGetJobExecution(final long jobExecutionId) {
       final EntityManager em = emProvider.newEntityManager();
       try {
       final JobExecutionEntity instance = em.find(JobExecutionEntity.class, jobExecutionId);
      final JobExecutionImpl jobEx = new JobExecutionImpl(jobExecutionId, instance.getInstance().getJobInstanceId(), this);
       jobEx.setCreateTime(instance.getCreateTime());
       jobEx.setStartTime(instance.getStartTime());
       jobEx.setEndTime(instance.getEndTime());
       jobEx.setJobParameters(instance.getJobProperties());
       jobEx.setLastUpdateTime(instance.getUpdateTime());
       if (instance.getBatchStatus() != null) {
       jobEx.setBatchStatus(instance.getBatchStatus().name());
       }
       jobEx.setExitStatus(instance.getExitStatus());
       jobEx.setJobName(instance.getInstance().getName());
       return jobEx;
       } finally {
       emProvider.release(em);
       }
       }
      

       

      Since instance is null, we get a Nullpointer in line 422. So I guess this method should return null and the in JobOperatorImpl you would map that to a NoSuchJobExecutionException like you do in other methods. Btw: I'm not sure if other methods are also affected by this bug. At least the JPA impl for getJobInstance seems also buggy too me ..

       

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            Unassigned Unassigned
            chberger Christian Berger
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment