Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 1f347dc

Browse files
christophstroblmp911de
authored andcommitted
Add missing native image runtime hints for Jackson Page serialization.
Closes #3117 Original pull request: #3119
1 parent d560893 commit 1f347dc

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

‎src/main/java/org/springframework/data/web/aot/WebRuntimeHints.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@
1515
*/
1616
package org.springframework.data.web.aot;
1717

18+
import org.springframework.aot.hint.MemberCategory;
1819
import org.springframework.aot.hint.RuntimeHints;
1920
import org.springframework.aot.hint.RuntimeHintsRegistrar;
2021
import org.springframework.aot.hint.TypeReference;
22+
import org.springframework.data.web.PagedModel;
2123
import org.springframework.data.web.config.SpringDataJacksonConfiguration.PageModule;
2224
import org.springframework.lang.Nullable;
2325
import org.springframework.util.ClassUtils;
@@ -34,8 +36,30 @@ class WebRuntimeHints implements RuntimeHintsRegistrar {
3436
public void registerHints(RuntimeHints hints, @Nullable ClassLoader classLoader) {
3537

3638
if (ClassUtils.isPresent("com.fasterxml.jackson.databind.ObjectMapper", classLoader)) {
39+
40+
// Page Model for Jackson Rendering
41+
hints.reflection().registerType(org.springframework.data.web.PagedModel.class,
42+
MemberCategory.INVOKE_PUBLIC_METHODS);
43+
hints.reflection().registerType(PagedModel.PageMetadata.class, MemberCategory.INVOKE_PUBLIC_METHODS);
44+
45+
// Type that might not be seen otherwise
3746
hints.reflection().registerType(TypeReference.of("org.springframework.data.domain.Unpaged"),
3847
hint -> hint.onReachableType(PageModule.class));
48+
49+
// Jackson Converters used via @JsonSerialize in SpringDataJacksonConfiguration
50+
hints.reflection().registerType(
51+
TypeReference
52+
.of("org.springframework.data.web.config.SpringDataJacksonConfiguration$PageModule$PageModelConverter"),
53+
hint -> {
54+
hint.withMembers(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS, MemberCategory.INVOKE_PUBLIC_METHODS);
55+
hint.onReachableType(PageModule.class);
56+
});
57+
hints.reflection().registerType(TypeReference.of(
58+
"org.springframework.data.web.config.SpringDataJacksonConfiguration$PageModule$PlainPageSerializationWarning"),
59+
hint -> {
60+
hint.withMembers(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS, MemberCategory.INVOKE_PUBLIC_METHODS);
61+
hint.onReachableType(PageModule.class);
62+
});
3963
}
4064
}
4165
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /