From d050ae57322c92f9b1999dd902f03e91234a9531 Mon Sep 17 00:00:00 2001 From: Christoph Strobl Date: Wed, 7 Dec 2022 13:46:27 +0100 Subject: [PATCH] Exclude mongodb and data.mongodb namespaces from reflection contribution. In some cases the users domain model may hold references to spring data or MongoDB specific types which should not be included in the reflection configuration as they are part of the static runtime hints configuration. Closes #4248 Original pull request: #4249 --- .../aot/AotMongoRepositoryPostProcessor.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/aot/AotMongoRepositoryPostProcessor.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/aot/AotMongoRepositoryPostProcessor.java index 8e11b1e92..4e916efaf 100644 --- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/aot/AotMongoRepositoryPostProcessor.java +++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/aot/AotMongoRepositoryPostProcessor.java @@ -21,6 +21,7 @@ import org.springframework.data.mongodb.aot.MongoAotPredicates; import org.springframework.data.repository.config.AotRepositoryContext; import org.springframework.data.repository.config.RepositoryRegistrationAotProcessor; import org.springframework.data.util.TypeContributor; +import org.springframework.data.util.TypeUtils; /** * @author Christoph Strobl @@ -39,4 +40,13 @@ public class AotMongoRepositoryPostProcessor extends RepositoryRegistrationAotPr lazyLoadingProxyAotProcessor.registerLazyLoadingProxyIfNeeded(type, generationContext); }); } + + @Override + protected void contributeType(Class type, GenerationContext generationContext) { + + if (TypeUtils.type(type).isPartOf("org.springframework.data.mongodb", "com.mongodb")) { + return; + } + super.contributeType(type, generationContext); + } }