Added initial implementation of check for supported function signatures
This commit is contained in:
@@ -147,6 +147,7 @@ public class FunctionRegistration<T> implements BeanNameAware {
|
||||
*/
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
public <S> FunctionRegistration<S> wrap() {
|
||||
this.isFunctionSignatureSupported();
|
||||
FunctionRegistration<S> result;
|
||||
if (this.type == null) {
|
||||
result = (FunctionRegistration<S>) this;
|
||||
@@ -192,4 +193,12 @@ public class FunctionRegistration<T> implements BeanNameAware {
|
||||
}
|
||||
}
|
||||
|
||||
private void isFunctionSignatureSupported() {
|
||||
if (type != null) {
|
||||
Assert.isTrue(!(Mono.class.isAssignableFrom(this.type.getOutputWrapper())
|
||||
&& Mono.class.isAssignableFrom(this.type.getInputWrapper())),
|
||||
"Function<Mono, Mono> is not supported.");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@ import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.BeanCreationException;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.beans.factory.config.AbstractFactoryBean;
|
||||
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
|
||||
@@ -289,6 +290,11 @@ public class ContextFunctionCatalogAutoConfigurationTests {
|
||||
.isAssignableFrom(Mono.class);
|
||||
}
|
||||
|
||||
@Test(expected = BeanCreationException.class)
|
||||
public void monoToMonoNonVoidFunction() {
|
||||
create(MonoToMonoNonVoidConfiguration.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void messageFunction() {
|
||||
create(MessageConfiguration.class);
|
||||
@@ -867,6 +873,17 @@ public class ContextFunctionCatalogAutoConfigurationTests {
|
||||
|
||||
}
|
||||
|
||||
@EnableAutoConfiguration
|
||||
@Configuration
|
||||
protected static class MonoToMonoNonVoidConfiguration {
|
||||
|
||||
@Bean
|
||||
public Function<Mono<String>, Mono<String>> function() {
|
||||
return mono -> mono;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@EnableAutoConfiguration
|
||||
@Configuration
|
||||
protected static class MessageConfiguration {
|
||||
|
||||
Reference in New Issue
Block a user