Removed auto-fluxing Supplier result when Supplier is not reactive

This commit is contained in:
Oleg Zhurakousky
2019-07-26 15:33:26 +02:00
parent 74ca973bc9
commit 9b1e69f05d
4 changed files with 12 additions and 10 deletions

View File

@@ -433,7 +433,7 @@ public class BeanFactoryAwareFunctionRegistry
* This is ONLY relevant for web, so consider exposing some property or may be * This is ONLY relevant for web, so consider exposing some property or may be
* the fact that this is a rare case (Supplier) leave it temporarily as is. * the fact that this is a rare case (Supplier) leave it temporarily as is.
*/ */
return Flux.just(result); // return Flux.just(result);
} }
return result; return result;

View File

@@ -53,9 +53,9 @@ public abstract class SpringFunctionAppConfigurationTests {
@Test @Test
public void test() throws Exception { public void test() throws Exception {
Supplier<Flux<String>> function = this.catalog.lookup(Supplier.class, Supplier<String> function = this.catalog.lookup(Supplier.class,
"function0"); "function0");
assertThat(function.get().blockFirst()).isEqualTo("one"); assertThat(function.get()).isEqualTo("one");
} }
} }
@@ -66,9 +66,9 @@ public abstract class SpringFunctionAppConfigurationTests {
@Test @Test
public void test() throws Exception { public void test() throws Exception {
Supplier<Flux<Integer>> function = this.catalog.lookup(Supplier.class, Supplier<Integer> function = this.catalog.lookup(Supplier.class,
"function0|function1"); "function0|function1");
assertThat(function.get().blockFirst()).isEqualTo(3); assertThat(function.get()).isEqualTo(3);
} }
} }

View File

@@ -53,9 +53,9 @@ public abstract class SpringFunctionAppExplodedConfigurationTests {
@Test @Test
public void test() throws Exception { public void test() throws Exception {
Supplier<Flux<String>> function = this.catalog.lookup(Supplier.class, Supplier<String> function = this.catalog.lookup(Supplier.class,
"function0"); "function0");
assertThat(function.get().blockFirst()).isEqualTo("one"); assertThat(function.get()).isEqualTo("one");
} }
} }
@@ -67,9 +67,9 @@ public abstract class SpringFunctionAppExplodedConfigurationTests {
@Test @Test
public void test() throws Exception { public void test() throws Exception {
Supplier<Flux<Integer>> function = this.catalog.lookup(Supplier.class, Supplier<Integer> function = this.catalog.lookup(Supplier.class,
"function0|function1"); "function0|function1");
assertThat(function.get().blockFirst()).isEqualTo(3); assertThat(function.get()).isEqualTo(3);
} }
} }

View File

@@ -112,12 +112,14 @@ public class RequestProcessor {
return new FunctionWrapper(function, null); return new FunctionWrapper(function, null);
} }
@SuppressWarnings("rawtypes")
public Mono<ResponseEntity<?>> get(FunctionWrapper wrapper) { public Mono<ResponseEntity<?>> get(FunctionWrapper wrapper) {
if (wrapper.function() != null) { if (wrapper.function() != null) {
return response(wrapper, wrapper.function(), value(wrapper), true, true); return response(wrapper, wrapper.function(), value(wrapper), true, true);
} }
else { else {
return response(wrapper, wrapper.supplier(), wrapper.supplier().get(), null, Object result = wrapper.supplier().get();
return response(wrapper, wrapper.supplier(), result instanceof Publisher ? (Publisher) result : Flux.just(result), null,
true); true);
} }