GH-947 Ensure FunctionAroundWrapper is not registered
In 4.x it will not since it is not a function, but here we needed a filtering logic during the default lookup Resolves #947
This commit is contained in:
@@ -19,7 +19,9 @@ package org.springframework.cloud.function.context.catalog;
|
|||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.lang.reflect.ParameterizedType;
|
import java.lang.reflect.ParameterizedType;
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.function.BiConsumer;
|
import java.util.function.BiConsumer;
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
@@ -90,6 +92,18 @@ public class BeanFactoryAwareFunctionRegistry extends SimpleFunctionRegistry imp
|
|||||||
@Override
|
@Override
|
||||||
public Set<String> getNames(Class<?> type) {
|
public Set<String> getNames(Class<?> type) {
|
||||||
Set<String> registeredNames = super.getNames(type);
|
Set<String> registeredNames = super.getNames(type);
|
||||||
|
|
||||||
|
//--- see https://github.com/spring-cloud/spring-cloud-function/issues/947
|
||||||
|
Set<String> arroundWrapperNeamnames = this.applicationContext.getBeansOfType(FunctionAroundWrapper.class).keySet();
|
||||||
|
String[] names = this.applicationContext.getBeanNamesForType(BiFunction.class);
|
||||||
|
List<String> biFunctions = new ArrayList<>();
|
||||||
|
for (int i = 0; i < names.length; i++) {
|
||||||
|
if (!arroundWrapperNeamnames.contains(names[i])) {
|
||||||
|
biFunctions.add(names[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
///
|
||||||
|
|
||||||
if (type == null) {
|
if (type == null) {
|
||||||
registeredNames
|
registeredNames
|
||||||
.addAll(Arrays.asList(this.applicationContext.getBeanNamesForType(Function.class)));
|
.addAll(Arrays.asList(this.applicationContext.getBeanNamesForType(Function.class)));
|
||||||
@@ -98,7 +112,7 @@ public class BeanFactoryAwareFunctionRegistry extends SimpleFunctionRegistry imp
|
|||||||
registeredNames
|
registeredNames
|
||||||
.addAll(Arrays.asList(this.applicationContext.getBeanNamesForType(Consumer.class)));
|
.addAll(Arrays.asList(this.applicationContext.getBeanNamesForType(Consumer.class)));
|
||||||
registeredNames
|
registeredNames
|
||||||
.addAll(Arrays.asList(this.applicationContext.getBeanNamesForType(BiFunction.class)));
|
.addAll(biFunctions);
|
||||||
registeredNames
|
registeredNames
|
||||||
.addAll(Arrays.asList(this.applicationContext.getBeanNamesForType(BiConsumer.class)));
|
.addAll(Arrays.asList(this.applicationContext.getBeanNamesForType(BiConsumer.class)));
|
||||||
registeredNames
|
registeredNames
|
||||||
|
|||||||
Reference in New Issue
Block a user