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);