diff --git a/pom.xml b/pom.xml
index 06b2eb92d1..6cd0ba8b96 100644
--- a/pom.xml
+++ b/pom.xml
@@ -127,6 +127,7 @@
9.4.13.0
6.8.0.RELEASE
6.1.0
+ 1.2.14
${spring-amqp.version}
diff --git a/spring-batch-core/pom.xml b/spring-batch-core/pom.xml
index 048a1e24f1..cefcb2f5b3 100644
--- a/spring-batch-core/pom.xml
+++ b/spring-batch-core/pom.xml
@@ -402,6 +402,12 @@
+
+ com.vmlens
+ api
+ ${vmlens.version}
+ test
+
@@ -412,4 +418,27 @@
+
+
+
+ com.vmlens
+ vmlens-maven-plugin
+ ${vmlens.version}
+
+
+ test
+
+ test
+
+
+
+
+
+ **/*CT.java
+
+
+
+
+
+
diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/MapStepRegistry.java b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/MapStepRegistry.java
index 051a44edd0..c26f925763 100644
--- a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/MapStepRegistry.java
+++ b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/MapStepRegistry.java
@@ -65,11 +65,11 @@ public void unregisterStepsFromJob(String jobName) {
public Step getStep(String jobName, String stepName) throws NoSuchJobException {
Assert.notNull(jobName, "The job name cannot be null.");
Assert.notNull(stepName, "The step name cannot be null.");
- if (!map.containsKey(jobName)) {
+ final Map jobSteps = map.get(jobName);
+ if (jobSteps == null) {
throw new NoSuchJobException("No job configuration with the name [" + jobName + "] was registered");
}
else {
- final Map jobSteps = map.get(jobName);
if (jobSteps.containsKey(stepName)) {
return jobSteps.get(stepName);
}
diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/support/MapStepRegistryCT.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/support/MapStepRegistryCT.java
new file mode 100644
index 0000000000..e3dfd158f1
--- /dev/null
+++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/support/MapStepRegistryCT.java
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2006-2023 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.springframework.batch.core.configuration.support;
+
+import com.vmlens.api.AllInterleavings;
+import org.junit.jupiter.api.Test;
+import org.springframework.batch.core.configuration.DuplicateJobException;
+import org.springframework.batch.core.configuration.StepRegistry;
+import org.springframework.batch.core.launch.NoSuchJobException;
+import org.springframework.batch.core.step.tasklet.TaskletStep;
+
+import java.util.List;
+
+/**
+ * @author Thomas Krieger
+ */
+public class MapStepRegistryCT {
+
+ @Test
+ public void unregisterAndGet() throws DuplicateJobException, InterruptedException {
+ try (AllInterleavings allInterleavings = new AllInterleavings("MapStepRegistryCT.unregisterAndGet")) {
+ while (allInterleavings.hasNext()) {
+ StepRegistry registry = new MapStepRegistry();
+ registry.register("foo", List.of(new TaskletStep("first")));
+ Thread first = new Thread() {
+ @Override
+ public void run() {
+ registry.unregisterStepsFromJob("foo");
+ }
+ };
+ first.start();
+ try {
+ registry.getStep("foo", "first");
+ }
+ catch (NoSuchJobException e) {
+
+ }
+ first.join();
+ }
+ }
+ }
+
+}