diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/jsr/JobExecution.java b/spring-batch-core/src/main/java/org/springframework/batch/core/jsr/JobExecution.java index c3a12badb..16541e54e 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/jsr/JobExecution.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/jsr/JobExecution.java @@ -114,6 +114,8 @@ public class JobExecution implements javax.batch.runtime.JobExecution { */ @Override public Properties getJobParameters() { - return parametersConverter.getProperties(this.execution.getJobParameters()); + Properties properties = parametersConverter.getProperties(this.execution.getJobParameters()); + properties.remove(JsrJobParametersConverter.JOB_RUN_ID); + return properties; } } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/jsr/launch/JsrJobOperator.java b/spring-batch-core/src/main/java/org/springframework/batch/core/jsr/launch/JsrJobOperator.java index 77c756da9..c3c6f1877 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/jsr/launch/JsrJobOperator.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/jsr/launch/JsrJobOperator.java @@ -45,6 +45,7 @@ import org.springframework.batch.core.JobParameters; import org.springframework.batch.core.converter.JobParametersConverter; import org.springframework.batch.core.explore.JobExplorer; import org.springframework.batch.core.jsr.JobContext; +import org.springframework.batch.core.jsr.JsrJobParametersConverter; import org.springframework.batch.core.jsr.configuration.support.BatchPropertyContext; import org.springframework.batch.core.repository.JobExecutionAlreadyRunningException; import org.springframework.batch.core.repository.JobRepository; @@ -320,7 +321,10 @@ public class JsrJobOperator implements JobOperator { throw new NoSuchJobExecutionException("Unable to find the JobExecution for id " + executionId); } - return jobParametersConverter.getProperties(execution.getJobParameters()); + Properties properties = jobParametersConverter.getProperties(execution.getJobParameters()); + properties.remove(JsrJobParametersConverter.JOB_RUN_ID); + + return properties; } /* (non-Javadoc) diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/jsr/JobExecutionTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/jsr/JobExecutionTests.java index 9b75bdd6a..116ade354 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/jsr/JobExecutionTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/jsr/JobExecutionTests.java @@ -1,6 +1,7 @@ package org.springframework.batch.core.jsr; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; import java.util.Date; import java.util.Properties; @@ -57,5 +58,6 @@ public class JobExecutionTests { Properties props = adapter.getJobParameters(); assertEquals("value1", props.get("key1")); + assertNull(props.get(JsrJobParametersConverter.JOB_RUN_ID)); } } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/jsr/launch/JsrJobOperatorTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/jsr/launch/JsrJobOperatorTests.java index ccff1fa68..18335e40c 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/jsr/launch/JsrJobOperatorTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/jsr/launch/JsrJobOperatorTests.java @@ -2,6 +2,7 @@ package org.springframework.batch.core.jsr.launch; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import static org.mockito.Mockito.verify; @@ -33,6 +34,7 @@ import org.springframework.batch.core.converter.JobParametersConverter; import org.springframework.batch.core.converter.JobParametersConverterSupport; import org.springframework.batch.core.explore.JobExplorer; import org.springframework.batch.core.explore.support.SimpleJobExplorer; +import org.springframework.batch.core.jsr.JsrJobParametersConverter; import org.springframework.batch.core.launch.support.SimpleJobOperator; import org.springframework.batch.core.repository.JobExecutionAlreadyRunningException; import org.springframework.batch.core.repository.JobRepository; @@ -252,13 +254,14 @@ public class JsrJobOperatorTests { @Test public void testGetParametersRoseyScenario() { - JobExecution jobExecution = new JobExecution(5l, new JobParametersBuilder().addString("key1", "value1").toJobParameters()); + JobExecution jobExecution = new JobExecution(5l, new JobParametersBuilder().addString("key1", "value1").addLong(JsrJobParametersConverter.JOB_RUN_ID, 5l).toJobParameters()); when(jobExplorer.getJobExecution(5l)).thenReturn(jobExecution); Properties params = jsrJobOperator.getParameters(5l); assertEquals("value1", params.get("key1")); + assertNull(params.get(JsrJobParametersConverter.JOB_RUN_ID)); } @Test(expected=NoSuchJobExecutionException.class)