From f3460bdec768f1f8c074245d56ac5f1ee2c19fea Mon Sep 17 00:00:00 2001 From: Artem Bilan Date: Sat, 24 Dec 2016 11:51:59 -0500 Subject: [PATCH] Compatibility with the latest SF https://build.spring.io/browse/INT-MJATS41-856 According the attempts to read method from class in the proper order, there is a fix in SF to do that via ASM. Therefore `beanDefinition.getSource()` isn't `StandardMethodMetadata` any more. Fortunately we can simply assert against `returnTypeName` to check for the `MessageHandler` See https://jira.spring.io/browse/SPR-14505 **Cherry-pick to 4.3.x** --- ...potentReceiverAutoProxyCreatorInitializer.java | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/spring-integration-core/src/main/java/org/springframework/integration/config/IdempotentReceiverAutoProxyCreatorInitializer.java b/spring-integration-core/src/main/java/org/springframework/integration/config/IdempotentReceiverAutoProxyCreatorInitializer.java index 2922ee2409..207e132c58 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/config/IdempotentReceiverAutoProxyCreatorInitializer.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/config/IdempotentReceiverAutoProxyCreatorInitializer.java @@ -20,6 +20,7 @@ import java.util.List; import java.util.Map; import org.springframework.beans.BeansException; +import org.springframework.beans.factory.CannotLoadBeanClassException; import org.springframework.beans.factory.annotation.AnnotatedBeanDefinition; import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; @@ -28,11 +29,11 @@ import org.springframework.beans.factory.support.BeanDefinitionRegistry; import org.springframework.beans.factory.support.ManagedList; import org.springframework.beans.factory.support.ManagedMap; import org.springframework.core.type.MethodMetadata; -import org.springframework.core.type.StandardMethodMetadata; import org.springframework.integration.annotation.IdempotentReceiver; import org.springframework.integration.handler.advice.IdempotentReceiverInterceptor; import org.springframework.messaging.MessageHandler; import org.springframework.util.Assert; +import org.springframework.util.ClassUtils; import org.springframework.util.StringUtils; /** @@ -82,8 +83,16 @@ public class IdempotentReceiverAutoProxyCreatorInitializer implements Integratio if (value != null) { String[] interceptors = (String[]) value; String endpoint = beanName; - if (!MessageHandler.class.isAssignableFrom( - ((StandardMethodMetadata) beanMethod).getIntrospectedMethod().getReturnType())) { + Class returnType; + try { + returnType = ClassUtils.forName(beanMethod.getReturnTypeName(), + beanFactory.getBeanClassLoader()); + } + catch (ClassNotFoundException e) { + throw new CannotLoadBeanClassException(beanDefinition.getDescription(), + beanName, beanMethod.getReturnTypeName(), e); + } + if (!MessageHandler.class.isAssignableFrom(returnType)) { /* MessageHandler beans, populated from @Bean methods, have a complex id, including @Configuration bean name, method name and the Messaging annotation name.