Skip to content

Commit

Permalink
Add missing hint for ResourceEditor
Browse files Browse the repository at this point in the history
  • Loading branch information
sdeleuze authored and mdeinum committed Jun 29, 2023
1 parent dca4e20 commit a2e98a9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
Expand Up @@ -17,8 +17,10 @@
package org.springframework.beans;

import org.springframework.aot.hint.MemberCategory;
import org.springframework.aot.hint.ReflectionHints;
import org.springframework.aot.hint.RuntimeHints;
import org.springframework.aot.hint.RuntimeHintsRegistrar;
import org.springframework.core.io.ResourceEditor;
import org.springframework.lang.Nullable;

/**
Expand All @@ -32,7 +34,9 @@ class BeanUtilsRuntimeHints implements RuntimeHintsRegistrar {

@Override
public void registerHints(RuntimeHints hints, @Nullable ClassLoader classLoader) {
hints.reflection().registerTypeIfPresent(classLoader, "org.springframework.http.MediaTypeEditor",
ReflectionHints reflectionHints = hints.reflection();
reflectionHints.registerType(ResourceEditor.class, MemberCategory.INVOKE_DECLARED_CONSTRUCTORS);
reflectionHints.registerTypeIfPresent(classLoader, "org.springframework.http.MediaTypeEditor",
MemberCategory.INVOKE_DECLARED_CONSTRUCTORS);
}

Expand Down
Expand Up @@ -24,6 +24,7 @@
import org.springframework.aot.hint.RuntimeHintsRegistrar;
import org.springframework.aot.hint.TypeReference;
import org.springframework.aot.hint.predicate.RuntimeHintsPredicates;
import org.springframework.core.io.ResourceEditor;
import org.springframework.core.io.support.SpringFactoriesLoader;
import org.springframework.util.ClassUtils;

Expand Down Expand Up @@ -52,4 +53,10 @@ void mediaTypeEditorHasHints() {
.withMemberCategories(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS)).accepts(this.hints);
}

@Test
void resourceEditorHasHints() {
assertThat(RuntimeHintsPredicates.reflection().onType(ResourceEditor.class)
.withMemberCategories(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS)).accepts(this.hints);
}

}

0 comments on commit a2e98a9

Please sign in to comment.