Uploaded image for project: 'Spring Integration'
  1. Spring Integration
  2. INT-4485

MessageChannelSpec-Bean causes BeanCurrentlyInCreationException

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Complete
    • Affects Version/s: 5.0.5
    • Fix Version/s: 5.1 M1, 5.0.6
    • Component/s: Core, DSL
    • Labels:

      Description

      The IntegrationFlowBeanPostProcessor seems to initialize channels - delivered as MessageChannelSpec - recursively, so that it raises Requested bean is currently in creation: Is there an unresolvable circular reference?.

      This simple config causes that behaviour:

      @Component
      public class IntegrationFlowConfig {
      
      @Bean
       public DirectChannelSpec myChannel() {
       return MessageChannels.direct("myChannel");
       }
      }
      

      Initializing the channel via .get() inside the bean works fine again.

      But this cannot be an option, so we overloaded the IntegrationFlowBeanPostProcessor as follows:

      @Component("org.springframework.integration.config.dsl.IntegrationFlowBeanPostProcessor")
      public class OverloadedIntegrationFlowBeanPostProcessor extends IntegrationFlowBeanPostProcessor {
      
        @Override
        public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
          if (bean instanceof MessageChannelSpec) {
            return bean;
          }
          return super.postProcessBeforeInitialization(bean, beanName);
        }
      }
      

      And that works on the whole project without changing code.

        Attachments

          Activity

            People

            • Assignee:
              abilan Artem Bilan
              Reporter:
              svenmaiwald Sven Maiwald
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: