Skip to content

Commit 4e33d0c

Browse files
committed
Add missing hint for ResourceEditor
Closes gh-30628
1 parent 9b4e0e9 commit 4e33d0c

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

spring-beans/src/main/java/org/springframework/beans/BeanUtilsRuntimeHints.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@
1717
package org.springframework.beans;
1818

1919
import org.springframework.aot.hint.MemberCategory;
20+
import org.springframework.aot.hint.ReflectionHints;
2021
import org.springframework.aot.hint.RuntimeHints;
2122
import org.springframework.aot.hint.RuntimeHintsRegistrar;
23+
import org.springframework.core.io.ResourceEditor;
2224
import org.springframework.lang.Nullable;
2325

2426
/**
@@ -32,7 +34,9 @@ class BeanUtilsRuntimeHints implements RuntimeHintsRegistrar {
3234

3335
@Override
3436
public void registerHints(RuntimeHints hints, @Nullable ClassLoader classLoader) {
35-
hints.reflection().registerTypeIfPresent(classLoader, "org.springframework.http.MediaTypeEditor",
37+
ReflectionHints reflectionHints = hints.reflection();
38+
reflectionHints.registerType(ResourceEditor.class, MemberCategory.INVOKE_DECLARED_CONSTRUCTORS);
39+
reflectionHints.registerTypeIfPresent(classLoader, "org.springframework.http.MediaTypeEditor",
3640
MemberCategory.INVOKE_DECLARED_CONSTRUCTORS);
3741
}
3842

spring-beans/src/test/java/org/springframework/beans/BeanUtilsRuntimeHintsTests.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import org.springframework.aot.hint.RuntimeHintsRegistrar;
2525
import org.springframework.aot.hint.TypeReference;
2626
import org.springframework.aot.hint.predicate.RuntimeHintsPredicates;
27+
import org.springframework.core.io.ResourceEditor;
2728
import org.springframework.core.io.support.SpringFactoriesLoader;
2829
import org.springframework.util.ClassUtils;
2930

@@ -52,4 +53,10 @@ void mediaTypeEditorHasHints() {
5253
.withMemberCategories(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS)).accepts(this.hints);
5354
}
5455

56+
@Test
57+
void resourceEditorHasHints() {
58+
assertThat(RuntimeHintsPredicates.reflection().onType(ResourceEditor.class)
59+
.withMemberCategories(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS)).accepts(this.hints);
60+
}
61+
5562
}

0 commit comments

Comments
 (0)