From d49fbbcf9c3ca09bfa13c623b954688805f264f4 Mon Sep 17 00:00:00 2001 From: Artem Bilan Date: Thu, 19 Jun 2014 09:11:13 +0300 Subject: [PATCH] INT-3445: Fix `PublisherRegistrar` NPE JIRA: https://jira.spring.io/browse/INT-3445 --- .../integration/config/PublisherRegistrar.java | 7 ++++--- .../AnnotatedEndpointActivationTests-context.xml | 2 ++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/spring-integration-core/src/main/java/org/springframework/integration/config/PublisherRegistrar.java b/spring-integration-core/src/main/java/org/springframework/integration/config/PublisherRegistrar.java index 49fa77a297..53ff997d0c 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/config/PublisherRegistrar.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/config/PublisherRegistrar.java @@ -22,6 +22,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.springframework.beans.MutablePropertyValues; +import org.springframework.beans.PropertyValue; import org.springframework.beans.factory.BeanDefinitionStoreException; import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.beans.factory.config.RuntimeBeanReference; @@ -64,15 +65,15 @@ public class PublisherRegistrar implements ImportBeanDefinitionRegistrar { else { BeanDefinition beanDefinition = registry.getBeanDefinition(IntegrationContextUtils.PUBLISHER_ANNOTATION_POSTPROCESSOR_NAME); MutablePropertyValues propertyValues = beanDefinition.getPropertyValues(); - RuntimeBeanReference defaultChannel = (RuntimeBeanReference) propertyValues.getPropertyValue("defaultChannel").getValue(); + PropertyValue defaultChannelPropertyValue = propertyValues.getPropertyValue("defaultChannel"); if (StringUtils.hasText(value)) { - if (defaultChannel == null) { + if (defaultChannelPropertyValue == null) { propertyValues.addPropertyValue("defaultChannel", new RuntimeBeanReference(value)); if (logger.isInfoEnabled()) { logger.info("Setting '@Publisher' default-output-channel to '" + value + "'."); } } - else if (!value.equals(defaultChannel.getBeanName())) { + else if (!value.equals(((RuntimeBeanReference) defaultChannelPropertyValue.getValue()).getBeanName())) { throw new BeanDefinitionStoreException("When more than one enable publisher definition " + "(@EnablePublisher or )" + " is found in the context, they all must have the same 'default-publisher-channel' value."); diff --git a/spring-integration-core/src/test/java/org/springframework/integration/config/annotation/AnnotatedEndpointActivationTests-context.xml b/spring-integration-core/src/test/java/org/springframework/integration/config/annotation/AnnotatedEndpointActivationTests-context.xml index 5eecbc6a13..c267f01b79 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/config/annotation/AnnotatedEndpointActivationTests-context.xml +++ b/spring-integration-core/src/test/java/org/springframework/integration/config/annotation/AnnotatedEndpointActivationTests-context.xml @@ -9,6 +9,8 @@ + +