spring-cloud / spring-cloud/spring-cloud-stream
Spring Cloud function is throwing error "Type must be one of Supplier, Function or Consumer" for non functional beans
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 1.1k
- Forks
- 646
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 8
Description
Issue:
Spring cloud function is not exluding custom java beans and it is expecting Supplier, Function or Consumer type.
related to https://github.com/spring-cloud/spring-cloud-stream/issues/2228
To Reproduce
Please find the attached sample project to recreate.
@Bean
public Function<String, String> uppercase() {
return v -> v.toUpperCase();
}
@Bean
public String value() {
return "hello";
}
Caused by: java.lang.IllegalArgumentException: Type must be one of Supplier, Function or Consumer
at org.springframework.util.Assert.isTrue(Assert.java:121) ~[spring-core-5.3.10.jar:5.3.10]
at org.springframework.cloud.function.context.catalog.FunctionTypeUtils.discoverFunctionTypeFromClass(FunctionTypeUtils.java:149) ~[spring-cloud-function-context-3.1.3.jar:3.1.3]
at org.springframework.cloud.function.context.catalog.FunctionTypeUtils.discoverFunctionType(FunctionTypeUtils.java:267) ~[spring-cloud-function-context-3.1.3.jar:3.1.3]
at org.springframework.cloud.stream.function.FunctionConfiguration$FunctionBindingRegistrar.filterEligibleFunctionDefinitions(FunctionConfiguration.java:907) ~[spring-cloud-stream-3.1.3.jar:3.1.3]
at org.springframework.cloud.stream.function.FunctionConfiguration$FunctionBindingRegistrar.afterPropertiesSet(FunctionConfiguration.java:796) ~[spring-cloud-stream-3.1.3.jar:3.1.3]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1863) ~[spring-beans-5.3.10.jar:5.3.10]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1800) ~[spring-beans-5.3.10.jar:5.3.10]
... 21 common frames omitted
Version of the framework
spring-cloud-function-core 3.1.3
spring-cloud-function-context 3.1.3
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with FunctionTypeUtils.java and FunctionConfiguration.java at the stack-trace locations, then run the attached functiontype.zip sample with the functional uppercase bean and non-functional value bean. Trace how bean definitions are classified; done means the sample starts without the type error while the Function bean remains eligible for binding.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring
- Domain
- stream-processing
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100