Skip to content
Permalink
Browse files
BATCHEE-127 fixed NPE if context not active
  • Loading branch information
rsandtner committed Nov 28, 2017
1 parent 38f3e98 commit 92ca9f78a0b42ee347a3448395ffe42d2e3c9b42
Showing 2 changed files with 14 additions and 2 deletions.
@@ -23,6 +23,7 @@
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.atomic.AtomicInteger;

import javax.batch.runtime.context.JobContext;
import javax.enterprise.inject.Typed;
import javax.enterprise.inject.spi.BeanManager;

@@ -44,7 +45,12 @@ public Class<? extends Annotation> getScope() {

@Override
protected Long currentKey() {
return getContextResolver().getJobContext().getExecutionId();
JobContext jobContext = getContextResolver().getJobContext();
if (jobContext == null) {
return null;
}

return jobContext.getExecutionId();
}


@@ -20,6 +20,7 @@

import java.lang.annotation.Annotation;

import javax.batch.runtime.context.StepContext;
import javax.enterprise.inject.Typed;
import javax.enterprise.inject.spi.BeanManager;

@@ -39,7 +40,12 @@ public Class<? extends Annotation> getScope() {

@Override
protected Long currentKey() {
return getContextResolver().getStepContext().getStepExecutionId();
StepContext stepContext = getContextResolver().getStepContext();
if (stepContext == null) {
return null;
}

return stepContext.getStepExecutionId();
}

public void exitStep() {

0 comments on commit 92ca9f7

Please sign in to comment.