Skip to content

Commit a99f446

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 34c454b commit a99f446

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/config/dsl/IntegrationFlowBeanPostProcessor.java

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

9191
private ConfigurableListableBeanFactory beanFactory;
9292

93-
private IntegrationFlowContext flowContext;
93+
private volatile IntegrationFlowContext flowContext;
9494

9595
@Override
9696
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
@@ -102,8 +102,6 @@ public void setApplicationContext(ApplicationContext applicationContext) throws
102102
this.applicationContext = (ConfigurableApplicationContext) applicationContext;
103103
this.beanFactory = this.applicationContext.getBeanFactory();
104104
this.embeddedValueResolver = new EmbeddedValueResolver(this.beanFactory);
105-
this.flowContext = this.beanFactory.getBean(IntegrationFlowContext.class);
106-
Assert.notNull(this.flowContext, "There must be an IntegrationFlowContext in the application context");
107105
}
108106

109107
@Override
@@ -137,6 +135,9 @@ public void afterSingletonsInstantiated() {
137135

138136
private Object processStandardIntegrationFlow(StandardIntegrationFlow flow, String flowBeanName) {
139137
String flowNamePrefix = flowBeanName + ".";
138+
if (this.flowContext == null) {
139+
this.flowContext = this.beanFactory.getBean(IntegrationFlowContext.class);
140+
}
140141
boolean useFlowIdAsPrefix = this.flowContext.isUseIdAsPrefix(flowBeanName);
141142
int subFlowNameIndex = 0;
142143
int channelNameIndex = 0;

0 commit comments

Comments
 (0)