Kafka Streams Binder Default Package Beans
Currently, in Kafka Streams binder-based apps, processor beans need to be declared public. This is unnecessary and caused by some restrictions in the binder. This PR fixes this restriction. Resolves https://github.com/spring-cloud/spring-cloud-stream/issues/2516
This commit is contained in:
@@ -93,7 +93,7 @@ public class FunctionDetectorCondition extends SpringBootCondition {
|
||||
ClassUtils.getDefaultClassLoader());
|
||||
try {
|
||||
|
||||
Method[] methods = classObj.getMethods();
|
||||
Method[] methods = classObj.getDeclaredMethods();
|
||||
Optional<Method> kafkaStreamMethod = Arrays.stream(methods).filter(m -> m.getName().equals(key)).findFirst();
|
||||
// check if the bean name is overridden.
|
||||
if (kafkaStreamMethod.isEmpty()) {
|
||||
|
||||
@@ -175,7 +175,7 @@ public class KafkaStreamsFunctionBeanPostProcessor implements InitializingBean,
|
||||
.getMetadata().getClassName(),
|
||||
ClassUtils.getDefaultClassLoader());
|
||||
try {
|
||||
Method[] methods = classObj.getMethods();
|
||||
Method[] methods = classObj.getDeclaredMethods();
|
||||
Optional<Method> functionalBeanMethods = Arrays.stream(methods).filter(m -> m.getName().equals(key)).findFirst();
|
||||
if (functionalBeanMethods.isEmpty()) {
|
||||
final BeanDefinition beanDefinition = this.beanFactory.getBeanDefinition(key);
|
||||
|
||||
@@ -391,7 +391,7 @@ public class KafkaStreamsBinderWordCountFunctionTests {
|
||||
InteractiveQueryService interactiveQueryService;
|
||||
|
||||
@Bean
|
||||
public Function<KStream<Object, String>, KStream<String, WordCount>> process() {
|
||||
Function<KStream<Object, String>, KStream<String, WordCount>> process() {
|
||||
|
||||
return input -> input
|
||||
.flatMapValues(value -> Arrays.asList(value.toLowerCase().split("\\W+")))
|
||||
@@ -405,7 +405,7 @@ public class KafkaStreamsBinderWordCountFunctionTests {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public StreamsBuilderFactoryBeanConfigurer customizer() {
|
||||
StreamsBuilderFactoryBeanConfigurer customizer() {
|
||||
return fb -> {
|
||||
try {
|
||||
fb.setStateListener((newState, oldState) -> {
|
||||
@@ -422,7 +422,7 @@ public class KafkaStreamsBinderWordCountFunctionTests {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public StreamPartitioner<String, WordCount> streamPartitioner() {
|
||||
StreamPartitioner<String, WordCount> streamPartitioner() {
|
||||
return (t, k, v, n) -> k.equals("foo") ? 0 : 1;
|
||||
}
|
||||
}
|
||||
@@ -431,7 +431,7 @@ public class KafkaStreamsBinderWordCountFunctionTests {
|
||||
static class OutboundNullApplication {
|
||||
|
||||
@Bean
|
||||
public Function<KStream<Object, String>, KStream<?, WordCount>> process() {
|
||||
Function<KStream<Object, String>, KStream<?, WordCount>> process() {
|
||||
return input -> input
|
||||
.flatMapValues(
|
||||
value -> Arrays.asList(value.toLowerCase().split("\\W+")))
|
||||
|
||||
Reference in New Issue
Block a user