From d44feadc79dabde4cf37b14ecc47a85efe1b907c Mon Sep 17 00:00:00 2001 From: Alexander Shaklein Date: Sat, 4 Jul 2020 22:58:49 +0300 Subject: [PATCH] GH-3324. fix NPE in StdIntFlowContext Fixes https://github.com/spring-projects/spring-integration/issues/3324 The `StandardIntegrationFlowContext.remove()` has a possible NPE **Cherry-pick to 5.3.x & 5.2.x** (cherry picked from commit 7424cb215c3ea9a6a408992d50461973698c5c98) --- .../dsl/context/StandardIntegrationFlowContext.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/spring-integration-core/src/main/java/org/springframework/integration/dsl/context/StandardIntegrationFlowContext.java b/spring-integration-core/src/main/java/org/springframework/integration/dsl/context/StandardIntegrationFlowContext.java index 3ba73336a6..2200ee03b5 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/dsl/context/StandardIntegrationFlowContext.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/dsl/context/StandardIntegrationFlowContext.java @@ -44,6 +44,7 @@ import org.springframework.util.StringUtils; * * @author Artem Bilan * @author Gary Russell + * @author Alexander Shaklein * * @since 5.1 * @@ -177,8 +178,8 @@ public final class StandardIntegrationFlowContext implements IntegrationFlowCont */ @Override public void remove(String flowId) { - if (this.registry.containsKey(flowId)) { - IntegrationFlowRegistration flowRegistration = this.registry.remove(flowId); + final IntegrationFlowRegistration flowRegistration = this.registry.remove(flowId); + if (flowRegistration != null) { flowRegistration.stop(); removeDependantBeans(flowId);