Skip to content

Commit 04264ef

Browse files
committed
GH-9745: IntEvalCtxFB: Use BeanFactory's ClassLoader
Fixes: #9745 Issue link: #9745 The `IntegrationEvaluationContextFactoryBean` does not provide a `TypeLocator` by default. That may lead to a class-not-found problem from different `ClassLoader` in the parallel Java `Stream` executor. * Fix `IntegrationEvaluationContextFactoryBean` to use a `StandardTypeLocator` based on the `applicationContext.getClassLoader()` (cherry picked from commit 6184c40) # Conflicts: # spring-integration-core/src/main/java/org/springframework/integration/config/IntegrationEvaluationContextFactoryBean.java
1 parent e894b5d commit 04264ef

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

spring-integration-core/src/main/java/org/springframework/integration/config/IntegrationEvaluationContextFactoryBean.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2013-2019 the original author or authors.
2+
* Copyright 2013-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -20,13 +20,16 @@
2020
import java.util.Map.Entry;
2121

2222
import org.springframework.beans.factory.FactoryBean;
23+
import org.springframework.context.ApplicationContext;
2324
import org.springframework.context.expression.BeanFactoryResolver;
2425
import org.springframework.context.expression.MapAccessor;
2526
import org.springframework.expression.BeanResolver;
2627
import org.springframework.expression.PropertyAccessor;
2728
import org.springframework.expression.TypeLocator;
2829
import org.springframework.expression.spel.support.StandardEvaluationContext;
30+
import org.springframework.expression.spel.support.StandardTypeLocator;
2931
import org.springframework.integration.context.IntegrationContextUtils;
32+
import org.springframework.lang.Nullable;
3033

3134
/**
3235
* <p>
@@ -65,7 +68,8 @@
6568
public class IntegrationEvaluationContextFactoryBean extends AbstractEvaluationContextFactoryBean
6669
implements FactoryBean<StandardEvaluationContext> {
6770

68-
private volatile TypeLocator typeLocator;
71+
@Nullable
72+
private TypeLocator typeLocator;
6973

7074
private BeanResolver beanResolver;
7175

@@ -80,8 +84,12 @@ public boolean isSingleton() {
8084

8185
@Override
8286
public void afterPropertiesSet() {
83-
if (getApplicationContext() != null) {
84-
this.beanResolver = new BeanFactoryResolver(getApplicationContext());
87+
ApplicationContext applicationContext = getApplicationContext();
88+
if (applicationContext != null) {
89+
this.beanResolver = new BeanFactoryResolver(applicationContext);
90+
if (this.typeLocator == null) {
91+
this.typeLocator = new StandardTypeLocator(applicationContext.getClassLoader());
92+
}
8593
}
8694
initialize(IntegrationContextUtils.INTEGRATION_EVALUATION_CONTEXT_BEAN_NAME);
8795
}

0 commit comments

Comments
 (0)