Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -144,8 +143,9 @@ public List<DisruptorEventDispatcher> create(DisruptorProperties properties) {
protected DisruptorEventDispatcher createDisruptorEventHandler(EventHandlerDefinition handlerDefinition,
Map<String, DisruptorHandler<DisruptorEvent>> 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());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, DisruptorHandler<DisruptorEvent>> handlers = Map.of(
"handler1", mock(DisruptorHandler.class));

assertThat(creater.createDisruptorEventHandler(definition, handlers)).isNotNull();
}

@Test
void parseHandlerChainDefinitions_shouldParseUrlsSection() {
ApplicationContext mockCtx = mock(ApplicationContext.class);
Expand Down
Loading