GH-363 Fixed NPE on AbstractBeanDefinition.getBeanClass() call
Resolves #363
This commit is contained in:
@@ -204,14 +204,14 @@ public abstract class AbstractComposableFunctionRegistry implements FunctionRegi
|
||||
*/
|
||||
protected void register(FunctionRegistration<?> registration, String key) {
|
||||
Object target = registration.getTarget();
|
||||
if (key.equals("uppercase")) {
|
||||
System.out.println();
|
||||
}
|
||||
if (registration.getType() != null) {
|
||||
this.addType(key, registration.getType());
|
||||
}
|
||||
else {
|
||||
FunctionType functionType = findType(registration, key);
|
||||
if (functionType == null) {
|
||||
return; // TODO fixme
|
||||
}
|
||||
this.addType(key, functionType);
|
||||
registration.type(functionType.getType());
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package org.springframework.cloud.function.context.config;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
@@ -156,13 +157,17 @@ public class ContextFunctionCatalogAutoConfiguration {
|
||||
if (functionType == null) {
|
||||
functionType = functionByNameExist(name)
|
||||
? new FunctionType(functionRegistration.getTarget().getClass())
|
||||
: new FunctionType(
|
||||
FunctionContextUtils.findType(name, this.beanFactory));
|
||||
: this.findType(name);
|
||||
}
|
||||
|
||||
return functionType;
|
||||
}
|
||||
|
||||
private FunctionType findType(String name) {
|
||||
Type type = FunctionContextUtils.findType(name, this.beanFactory);
|
||||
return type == null ? null : new FunctionType(type);
|
||||
}
|
||||
|
||||
// @checkstyle:off
|
||||
/**
|
||||
* @param initial a registration
|
||||
|
||||
@@ -67,16 +67,17 @@ public abstract class FunctionContextUtils {
|
||||
param = type.getType();
|
||||
}
|
||||
else {
|
||||
Class<?> beanClass = definition.getBeanClass();
|
||||
Class<?> beanClass = definition.hasBeanClass() ? definition.getBeanClass() : null;
|
||||
if (beanClass != null
|
||||
&& !FunctionFactoryMetadata.class.isAssignableFrom(beanClass)) {
|
||||
param = beanClass;
|
||||
}
|
||||
else {
|
||||
// assume FunctionFactoryMetadata
|
||||
FunctionFactoryMetadata<?> factory = (FunctionFactoryMetadata<?>) registry
|
||||
.getBean(name);
|
||||
param = factory.getFactoryMethod().getGenericReturnType();
|
||||
Object bean = registry.getBean(name);
|
||||
// could be FunctionFactoryMetadata. . . TODO investigate and fix
|
||||
if (bean instanceof FunctionFactoryMetadata) {
|
||||
param = ((FunctionFactoryMetadata<?>) bean).getFactoryMethod().getGenericReturnType();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user