From 8cf5e6282052a3d72a336f79bc3a244a62d5fd50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B5=D1=80=D0=B3=D0=B5=D0=B9=20=D0=A6=D1=8B=D0=BF?= =?UTF-8?q?=D0=B0=D0=BD=D0=BE=D0=B2?= Date: Fri, 6 Nov 2020 22:36:13 +0200 Subject: [PATCH] Don't check bridge and synthetic methods in postProcessAfterInitialization() Resolves #2046 --- .../StreamListenerAnnotationBeanPostProcessor.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) 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 08a3dcb0f..5dae4c3b9 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 @@ -1,5 +1,5 @@ /* - * Copyright 2016-2017 the original author or authors. + * Copyright 2016-2020 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -190,11 +190,11 @@ public class StreamListenerAnnotationBeanPostProcessor implements BeanPostProces Class targetClass = AopUtils.isAopProxy(bean) ? AopUtils.getTargetClass(bean) : bean.getClass(); Method[] uniqueDeclaredMethods = ReflectionUtils - .getUniqueDeclaredMethods(targetClass); + .getUniqueDeclaredMethods(targetClass, ReflectionUtils.USER_DECLARED_METHODS); for (Method method : uniqueDeclaredMethods) { StreamListener streamListener = AnnotatedElementUtils .findMergedAnnotation(method, StreamListener.class); - if (streamListener != null && !method.isBridge()) { + if (streamListener != null) { this.streamListenerPresent = true; this.streamListenerCallbacks.add(() -> { Assert.isTrue(method.getAnnotation(Input.class) == null, @@ -336,7 +336,7 @@ public class StreamListenerAnnotationBeanPostProcessor implements BeanPostProces this.streamListenerCallbacks.forEach(Runnable::run); } - private class StreamListenerHandlerMethodMapping { + private static class StreamListenerHandlerMethodMapping { private final Object targetBean; @@ -447,7 +447,7 @@ public class StreamListenerAnnotationBeanPostProcessor implements BeanPostProces Object result = method.invoke(bean, arguments); if (!StringUtils.hasText(outboundName)) { for (int parameterIndex = 0; parameterIndex < method - .getParameterTypes().length; parameterIndex++) { + .getParameterCount(); parameterIndex++) { MethodParameter methodParameter = MethodParameter .forExecutable(method, parameterIndex); if (methodParameter.hasParameterAnnotation(Output.class)) { @@ -499,7 +499,7 @@ public class StreamListenerAnnotationBeanPostProcessor implements BeanPostProces private boolean checkDeclarativeMethod(Method method, String methodAnnotatedInboundName, String methodAnnotatedOutboundName) { - int methodArgumentsLength = method.getParameterTypes().length; + int methodArgumentsLength = method.getParameterCount(); for (int parameterIndex = 0; parameterIndex < methodArgumentsLength; parameterIndex++) { MethodParameter methodParameter = MethodParameter.forExecutable(method, parameterIndex);