You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@batchee.apache.org by "Romain Manni-Bucau (Jira)" <ji...@apache.org> on 2020/04/09 12:48:00 UTC

[jira] [Commented] (BATCHEE-139) JPAPersistenceManagerService throws a Nullpointer in case an invalid execution id is passed to getJobExecution

    [ https://issues.apache.org/jira/browse/BATCHEE-139?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17079292#comment-17079292 ] 

Romain Manni-Bucau commented on BATCHEE-139:
--------------------------------------------

Hi [~chberger], nice finding! Feel free to submit a PR to [https://github.com/apache/geronimo-batchee], I would be happy to review and merge it.

> JPAPersistenceManagerService throws a Nullpointer in case an invalid execution id is passed to getJobExecution
> --------------------------------------------------------------------------------------------------------------
>
>                 Key: BATCHEE-139
>                 URL: https://issues.apache.org/jira/browse/BATCHEE-139
>             Project: BatchEE
>          Issue Type: Bug
>          Components: jbatch-core
>    Affects Versions: 0.5-incubating
>            Reporter: Christian Berger
>            Priority: Minor
>
> HI BatchEE-Team,
> I'm using the
> {noformat}
> org.apache.batchee.container.services.persistenceJPAPersistenceManagerService{noformat}
> 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.
>  
> {noformat}
> getJobExecution(final long executionId) throws NoSuchJobExecutionException, JobSecurityException{noformat}
> As you can see the method signature illustrates that I would get a NoSuchJobExecutionException, rather than a Nullpointer which I'm facing ..
> {code:java}
> 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){code}
> I've just checked the code and at least the implementation of jobOperatorGetJobExecution would need to be changed:
>  
> {code:java}
> @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);
>  }
>  }
> {code}
>  
> 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 ..
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)