From a118d26dc3145634b24593616deb7460e6dab007 Mon Sep 17 00:00:00 2001 From: Christoph Strobl Date: Tue, 2 Jul 2024 15:23:16 +0200 Subject: [PATCH 1/2] Prepare issue branch. --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 77d72c255e..6b7b819dd9 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ org.springframework.data spring-data-commons - 3.4.0-SNAPSHOT + 3.4.x-GH-3117-SNAPSHOT Spring Data Core Core Spring concepts underpinning every Spring Data module. From cb52d9ee92b9b2e2860b4f833faaf11acfd6412d Mon Sep 17 00:00:00 2001 From: Christoph Strobl Date: Wed, 3 Jul 2024 09:09:21 +0200 Subject: [PATCH 2/2] Add missing native image runtime hints for Jackson Page serialization. --- .../data/web/aot/WebRuntimeHints.java | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/main/java/org/springframework/data/web/aot/WebRuntimeHints.java b/src/main/java/org/springframework/data/web/aot/WebRuntimeHints.java index f791ce4981..3a9aee614b 100644 --- a/src/main/java/org/springframework/data/web/aot/WebRuntimeHints.java +++ b/src/main/java/org/springframework/data/web/aot/WebRuntimeHints.java @@ -15,9 +15,11 @@ */ package org.springframework.data.web.aot; +import org.springframework.aot.hint.MemberCategory; import org.springframework.aot.hint.RuntimeHints; import org.springframework.aot.hint.RuntimeHintsRegistrar; import org.springframework.aot.hint.TypeReference; +import org.springframework.data.web.PagedModel; import org.springframework.data.web.config.SpringDataJacksonConfiguration.PageModule; import org.springframework.lang.Nullable; import org.springframework.util.ClassUtils; @@ -34,8 +36,30 @@ class WebRuntimeHints implements RuntimeHintsRegistrar { public void registerHints(RuntimeHints hints, @Nullable ClassLoader classLoader) { if (ClassUtils.isPresent("com.fasterxml.jackson.databind.ObjectMapper", classLoader)) { + + // Page Model for Jackson Rendering + hints.reflection().registerType(org.springframework.data.web.PagedModel.class, + MemberCategory.INVOKE_PUBLIC_METHODS); + hints.reflection().registerType(PagedModel.PageMetadata.class, MemberCategory.INVOKE_PUBLIC_METHODS); + + // Type that might not be seen otherwise hints.reflection().registerType(TypeReference.of("org.springframework.data.domain.Unpaged"), hint -> hint.onReachableType(PageModule.class)); + + // Jackson Converters used via @JsonSerialize in SpringDataJacksonConfiguration + hints.reflection().registerType( + TypeReference + .of("org.springframework.data.web.config.SpringDataJacksonConfiguration$PageModule$PageModelConverter"), + hint -> { + hint.withMembers(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS, MemberCategory.INVOKE_PUBLIC_METHODS); + hint.onReachableType(PageModule.class); + }); + hints.reflection().registerType(TypeReference.of( + "org.springframework.data.web.config.SpringDataJacksonConfiguration$PageModule$PlainPageSerializationWarning"), + hint -> { + hint.withMembers(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS, MemberCategory.INVOKE_PUBLIC_METHODS); + hint.onReachableType(PageModule.class); + }); } } }