From aa306fac9aceee87b396ce507f56e2cfd54569f1 Mon Sep 17 00:00:00 2001 From: Oleg Zhurakousky Date: Tue, 12 Mar 2019 20:05:11 +0100 Subject: [PATCH] Made StreamListenerAnnotationBeanPostProcessor initialization optional based on presence of @StreamListener --- .../binding/StreamListenerAnnotationBeanPostProcessor.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/binding/StreamListenerAnnotationBeanPostProcessor.java b/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/binding/StreamListenerAnnotationBeanPostProcessor.java index 553f1e96f..a00df90ba 100644 --- a/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/binding/StreamListenerAnnotationBeanPostProcessor.java +++ b/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/binding/StreamListenerAnnotationBeanPostProcessor.java @@ -98,6 +98,8 @@ public class StreamListenerAnnotationBeanPostProcessor implements BeanPostProces private Set streamListenerSetupMethodOrchestrators = new LinkedHashSet<>(); + private boolean streamListenerPresent; + @Override public final void setApplicationContext(ApplicationContext applicationContext) throws BeansException { @@ -110,6 +112,9 @@ public class StreamListenerAnnotationBeanPostProcessor implements BeanPostProces @Override public final void afterSingletonsInstantiated() { + if (!this.streamListenerPresent) { + return; + } this.injectAndPostProcessDependencies(); EvaluationContext evaluationContext = IntegrationContextUtils .getEvaluationContext(this.applicationContext.getBeanFactory()); @@ -190,6 +195,7 @@ public class StreamListenerAnnotationBeanPostProcessor implements BeanPostProces StreamListener streamListener = AnnotatedElementUtils .findMergedAnnotation(method, StreamListener.class); if (streamListener != null && !method.isBridge()) { + this.streamListenerPresent = true; this.streamListenerCallbacks.add(() -> { Assert.isTrue(method.getAnnotation(Input.class) == null, StreamListenerErrorMessages.INPUT_AT_STREAM_LISTENER);