GH-2820: Component beans and function return types

- When Kafka Streams functions are provided as component beans,
   the function type check in the core Spring Cloud Stream framework,
   fails with an NPE. Addressing this issue.

Resolves https://github.com/spring-cloud/spring-cloud-stream/issues/2820
This commit is contained in:
Soby Chacko
2023-09-29 17:00:07 -04:00
parent 3a52c3b3cf
commit d1a0aff623

View File

@@ -1026,11 +1026,15 @@ public class FunctionConfiguration {
if (this.applicationContext.containsBean(functionName)) {
Object functionBean = this.applicationContext.getBean(functionName);
Type functionType = FunctionTypeUtils.discoverFunctionType(functionBean, functionName, (GenericApplicationContext) this.applicationContext);
String functionTypeStringValue = functionType.toString();
if (functionTypeStringValue.contains("KTable") || functionTypeStringValue.contains("KStream")) {
if (functionType == null) {
eligibleDefinition = false;
}
else {
String functionTypeStringValue = functionType.toString();
if (functionTypeStringValue.contains("KTable") || functionTypeStringValue.contains("KStream")) {
eligibleDefinition = false;
}
}
}
else {
logger.warn("You have defined function definition that does not exist: " + functionName);