From ae1aaad67a5d86715c3288e6ecb690c1552862f7 Mon Sep 17 00:00:00 2001 From: Zahid Khan <63726443+ZFK07@users.noreply.github.com> Date: Wed, 6 Jul 2022 23:48:34 +0530 Subject: [PATCH] Check for null before setting maxSubscribers The `DirectChannel` doesn't check a result of the `getIntegrationProperty()`. This may cause NPE problem with unconditional `setMaxSubscribers(int)` call. * Check `Integer max` for `null` before propagating to the `setMaxSubscribers()` --- .../springframework/integration/channel/DirectChannel.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/spring-integration-core/src/main/java/org/springframework/integration/channel/DirectChannel.java b/spring-integration-core/src/main/java/org/springframework/integration/channel/DirectChannel.java index 524e7db0c7..1e624852bf 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/channel/DirectChannel.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/channel/DirectChannel.java @@ -87,7 +87,9 @@ public class DirectChannel extends AbstractSubscribableChannel { super.onInit(); if (this.maxSubscribers == null) { Integer max = getIntegrationProperty(IntegrationProperties.CHANNELS_MAX_UNICAST_SUBSCRIBERS, Integer.class); - setMaxSubscribers(max); + if (max != null) { + setMaxSubscribers(max); + } } }