Prefer explicit route to default

This commit is contained in:
Dave Syer
2017-11-24 13:21:08 +09:00
parent 0e21a30459
commit f3951cba66
5 changed files with 38 additions and 11 deletions

View File

@@ -250,7 +250,7 @@ public class ContextFunctionCatalogAutoConfiguration {
if (stages.length == 0 && source.size() == 1) {
stages = new String[] { source.keySet().iterator().next() };
}
Object function = lookup(stages[0], source);
Object function = stages.length>0 ? lookup(stages[0], source) : null;
if (function == null) {
return null;
}

View File

@@ -54,6 +54,13 @@ public class BeanFactoryFunctionCatalogTests {
assertThat(foos.apply(Flux.just(2)).blockFirst()).isEqualTo("4");
}
@Test
public void lookupNonExistentConsumerWithEmptyName() {
processor.register(new FunctionRegistration<>(new Foos()).names("foos"));
Consumer<Flux<String>> foos = processor.lookupConsumer("");
assertThat(foos).isNull();
}
@Test
public void composeFunction() {
processor.register(new FunctionRegistration<>(new Foos()).names("foos"));