Skip to content

Commit de9f8d7

Browse files
committed
INT-4501: Don't call getBean from BPP.setBFactory
JIRA: https://jira.spring.io/browse/INT-4501 The call to the `IntegrationFlowBeanPostProcessor#setBeanFactory` happens during BPP creation. The introduced call to `beanFactory#getBean` triggers a lot of bean creations. For those beans not all `BPP`s are applied. * Obtain a `flowContext` bean in lazy-load manner **Cherry-pick to 5.0.x**
1 parent aac4051 commit de9f8d7

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

spring-integration-core/src/main/java/org/springframework/integration/dsl/context/IntegrationFlowBeanPostProcessor.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public class IntegrationFlowBeanPostProcessor
9393

9494
private ConfigurableListableBeanFactory beanFactory;
9595

96-
private IntegrationFlowContext flowContext;
96+
private volatile IntegrationFlowContext flowContext;
9797

9898
@Override
9999
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
@@ -105,8 +105,6 @@ public void setApplicationContext(ApplicationContext applicationContext) throws
105105
this.applicationContext = (ConfigurableApplicationContext) applicationContext;
106106
this.beanFactory = this.applicationContext.getBeanFactory();
107107
this.embeddedValueResolver = new EmbeddedValueResolver(this.beanFactory);
108-
this.flowContext = this.beanFactory.getBean(IntegrationFlowContext.class);
109-
Assert.notNull(this.flowContext, "There must be an IntegrationFlowContext in the application context");
110108
}
111109

112110
@Override
@@ -140,6 +138,9 @@ public void afterSingletonsInstantiated() {
140138

141139
private Object processStandardIntegrationFlow(StandardIntegrationFlow flow, String flowBeanName) {
142140
String flowNamePrefix = flowBeanName + ".";
141+
if (this.flowContext == null) {
142+
this.flowContext = this.beanFactory.getBean(IntegrationFlowContext.class);
143+
}
143144
boolean useFlowIdAsPrefix = this.flowContext.isUseIdAsPrefix(flowBeanName);
144145
int subFlowNameIndex = 0;
145146
int channelNameIndex = 0;

0 commit comments

Comments
 (0)