GH-9745: IntEvalCtxFB: Use BeanFactory's ClassLoader
Fixes: #9745
Issue link: https://github.com/spring-projects/spring-integration/issues/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 6184c4082a)
This commit is contained in:
committed by
Spring Builds
parent
cf0dd02765
commit
b7b49862d3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2024 the original author or authors.
|
||||
* Copyright 2013-2025 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -20,6 +20,7 @@ import java.lang.reflect.Method;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.springframework.beans.factory.FactoryBean;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.expression.BeanFactoryResolver;
|
||||
import org.springframework.context.expression.MapAccessor;
|
||||
import org.springframework.expression.BeanResolver;
|
||||
@@ -27,7 +28,9 @@ import org.springframework.expression.IndexAccessor;
|
||||
import org.springframework.expression.PropertyAccessor;
|
||||
import org.springframework.expression.TypeLocator;
|
||||
import org.springframework.expression.spel.support.StandardEvaluationContext;
|
||||
import org.springframework.expression.spel.support.StandardTypeLocator;
|
||||
import org.springframework.integration.context.IntegrationContextUtils;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -66,7 +69,8 @@ import org.springframework.integration.context.IntegrationContextUtils;
|
||||
public class IntegrationEvaluationContextFactoryBean extends AbstractEvaluationContextFactoryBean
|
||||
implements FactoryBean<StandardEvaluationContext> {
|
||||
|
||||
private volatile TypeLocator typeLocator;
|
||||
@Nullable
|
||||
private TypeLocator typeLocator;
|
||||
|
||||
private BeanResolver beanResolver;
|
||||
|
||||
@@ -81,8 +85,12 @@ public class IntegrationEvaluationContextFactoryBean extends AbstractEvaluationC
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() {
|
||||
if (getApplicationContext() != null) {
|
||||
this.beanResolver = new BeanFactoryResolver(getApplicationContext());
|
||||
ApplicationContext applicationContext = getApplicationContext();
|
||||
if (applicationContext != null) {
|
||||
this.beanResolver = new BeanFactoryResolver(applicationContext);
|
||||
if (this.typeLocator == null) {
|
||||
this.typeLocator = new StandardTypeLocator(applicationContext.getClassLoader());
|
||||
}
|
||||
}
|
||||
initialize(IntegrationContextUtils.INTEGRATION_EVALUATION_CONTEXT_BEAN_NAME);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user