From 0aa96a59c5f26a6e9d4e2856f93bd63867dbfa47 Mon Sep 17 00:00:00 2001 From: loong10k <20489781+loong10k@users.noreply.github.com> Date: Sat, 31 Oct 2026 22:42:51 +0800 Subject: [PATCH] fix: replace removed Disruptor StringUtils check --- .../spring/boot/DisruptorEventHandlerCreater.java | 6 +++--- .../boot/DisruptorEventHandlerCreaterTest.java | 13 +++++++++++++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/lmax/disruptor/spring/boot/DisruptorEventHandlerCreater.java b/src/main/java/com/lmax/disruptor/spring/boot/DisruptorEventHandlerCreater.java index 9f3b0c6..951b006 100644 --- a/src/main/java/com/lmax/disruptor/spring/boot/DisruptorEventHandlerCreater.java +++ b/src/main/java/com/lmax/disruptor/spring/boot/DisruptorEventHandlerCreater.java @@ -10,7 +10,6 @@ import com.lmax.disruptor.event.handler.chain.HandlerChainManager; import com.lmax.disruptor.event.handler.chain.def.DefaultHandlerChainManager; import com.lmax.disruptor.event.handler.chain.def.PathMatchingHandlerChainResolver; -import com.lmax.disruptor.util.StringUtils; import lombok.extern.slf4j.Slf4j; import org.springframework.context.ApplicationContext; import org.springframework.core.OrderComparator; @@ -144,8 +143,9 @@ public List create(DisruptorProperties properties) { protected DisruptorEventDispatcher createDisruptorEventHandler(EventHandlerDefinition handlerDefinition, Map> eventHandlers) { - if (StringUtils.isNotEmpty(handlerDefinition.getDefinitions())) { - handlerChainDefinitionMap.putAll(this.parseHandlerChainDefinitions(handlerDefinition.getDefinitions())); + String definitions = handlerDefinition.getDefinitions(); + if (definitions != null && !definitions.isEmpty()) { + handlerChainDefinitionMap.putAll(this.parseHandlerChainDefinitions(definitions)); } else if (!CollectionUtils.isEmpty(handlerDefinition.getDefinitionMap())) { handlerChainDefinitionMap.putAll(handlerDefinition.getDefinitionMap()); } diff --git a/src/test/java/com/lmax/disruptor/spring/boot/DisruptorEventHandlerCreaterTest.java b/src/test/java/com/lmax/disruptor/spring/boot/DisruptorEventHandlerCreaterTest.java index e37b87e..dfe4726 100644 --- a/src/test/java/com/lmax/disruptor/spring/boot/DisruptorEventHandlerCreaterTest.java +++ b/src/test/java/com/lmax/disruptor/spring/boot/DisruptorEventHandlerCreaterTest.java @@ -169,6 +169,19 @@ void create_withDefinitionsWithStringAndMatchingHandler_shouldParseIni() { assertThat(dispatchers).hasSize(1); } + @Test + void emptyDefinitionStringUsesDefinitionMap() { + DisruptorEventHandlerCreater creater = new DisruptorEventHandlerCreater(mock(ApplicationContext.class)); + EventHandlerDefinition definition = new EventHandlerDefinition(); + definition.setDefinitions(""); + definition.setOrder(0); + definition.setDefinitionMap(Map.of("/**", "handler1")); + Map> handlers = Map.of( + "handler1", mock(DisruptorHandler.class)); + + assertThat(creater.createDisruptorEventHandler(definition, handlers)).isNotNull(); + } + @Test void parseHandlerChainDefinitions_shouldParseUrlsSection() { ApplicationContext mockCtx = mock(ApplicationContext.class);