Skip to content

Commit 2c72285

Browse files
committed
GH-3990: Fix JsonPath native hint registration
Fixes #3990 Turns out just being on the classpath doesn’t make the type reachable. If it’s only accessed reflectively then it’s not reachable. This is exaclt what happened with our `JsonPathUtils` which is used via reflection from SpEL when that calls its method via function reference * Change `onReachableType()` logic for `com.jayway.jsonpath.JsonPath` type to `ClassUtils.isPresent()` on `JsonPathUtils` reflection hint registration.
1 parent 9dd9f08 commit 2c72285

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

spring-integration-core/src/main/java/org/springframework/integration/aot/CoreRuntimeHints.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2022 the original author or authors.
2+
* Copyright 2022-2023 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.
@@ -34,7 +34,6 @@
3434
import org.springframework.aot.hint.RuntimeHints;
3535
import org.springframework.aot.hint.RuntimeHintsRegistrar;
3636
import org.springframework.aot.hint.SerializationHints;
37-
import org.springframework.aot.hint.TypeReference;
3837
import org.springframework.beans.factory.config.BeanExpressionContext;
3938
import org.springframework.context.SmartLifecycle;
4039
import org.springframework.integration.aggregator.MessageGroupProcessor;
@@ -66,6 +65,7 @@
6665
import org.springframework.messaging.ReactiveMessageHandler;
6766
import org.springframework.messaging.support.ErrorMessage;
6867
import org.springframework.messaging.support.GenericMessage;
68+
import org.springframework.util.ClassUtils;
6969
import org.springframework.util.ReflectionUtils;
7070

7171
/**
@@ -96,10 +96,10 @@ public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
9696
Pausable.class)
9797
.forEach(type -> reflectionHints.registerType(type, MemberCategory.INVOKE_PUBLIC_METHODS));
9898

99-
reflectionHints.registerType(JsonPathUtils.class,
100-
builder ->
101-
builder.onReachableType(TypeReference.of("com.jayway.jsonpath.JsonPath"))
102-
.withMembers(MemberCategory.INVOKE_PUBLIC_METHODS));
99+
100+
if (ClassUtils.isPresent("com.jayway.jsonpath.JsonPath", classLoader)) {
101+
reflectionHints.registerType(JsonPathUtils.class, MemberCategory.INVOKE_PUBLIC_METHODS);
102+
}
103103

104104
// For #xpath() SpEL function
105105
reflectionHints.registerTypeIfPresent(classLoader, "org.springframework.integration.xml.xpath.XPathUtils",

0 commit comments

Comments
 (0)