GH-3541: Properly guard when no json-path in CP (#3542)

Fixes https://github.com/spring-projects/spring-integration/issues/3541

* Fix `DefaultConfiguringBeanFactoryPostProcessor` to check for `jsonPath` bean
a `com.jayway.jsonpath.JsonPath` on CP instead of `JsonPathUtils`
which is always there since it is a part of `spring-integration-core`
* Remove `json-path` and `jackson-databind` from tests classpath
to be sure that we have coverage for the mentioned above option classpath entries
* Add `json-path` and `jackson-databind` into test classpath whenever it is necessary
This commit is contained in:
Artem Bilan
2021-04-09 11:57:29 -04:00
committed by GitHub
parent c57634f085
commit aa32270c5b
3 changed files with 29 additions and 17 deletions

View File

@@ -58,6 +58,7 @@ import org.springframework.integration.handler.support.MapArgumentResolver;
import org.springframework.integration.handler.support.PayloadExpressionArgumentResolver;
import org.springframework.integration.handler.support.PayloadsArgumentResolver;
import org.springframework.integration.json.JsonNodeWrapperToJsonNodeConverter;
import org.springframework.integration.json.JsonPathUtils;
import org.springframework.integration.support.DefaultMessageBuilderFactory;
import org.springframework.integration.support.NullAwarePayloadArgumentResolver;
import org.springframework.integration.support.SmartLifecycleRoleController;
@@ -121,8 +122,7 @@ class DefaultConfiguringBeanFactoryPostProcessor
Class<?> jsonPathClass = null;
try {
jsonPathClass = ClassUtils.forName(IntegrationConfigUtils.BASE_PACKAGE + ".json.JsonPathUtils",
ClassUtils.getDefaultClassLoader());
jsonPathClass = ClassUtils.forName("com.jayway.jsonpath.JsonPath", ClassUtils.getDefaultClassLoader());
}
catch (@SuppressWarnings("unused") ClassNotFoundException e) {
LOGGER.debug("The '#jsonPath' SpEL function cannot be registered: " +
@@ -406,7 +406,8 @@ class DefaultConfiguringBeanFactoryPostProcessor
&& !this.beanFactory.containsBean(jsonPathBeanName)
&& !REGISTRIES_PROCESSED.contains(registryId)) {
IntegrationConfigUtils.registerSpelFunctionBean(this.registry, jsonPathBeanName, JSON_PATH_CLASS, "evaluate");
IntegrationConfigUtils.registerSpelFunctionBean(this.registry, jsonPathBeanName,
JsonPathUtils.class, "evaluate");
}
}