From 2ad4aa092ebc427a5053b71b0cf8385f6eb5c390 Mon Sep 17 00:00:00 2001 From: Gerrit Meier Date: Tue, 30 Jan 2024 17:57:24 +0100 Subject: [PATCH] GH-2858 - Fix potential stackoverflow in recursive projections. --- .../data/neo4j/core/PropertyFilterSupport.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/springframework/data/neo4j/core/PropertyFilterSupport.java b/src/main/java/org/springframework/data/neo4j/core/PropertyFilterSupport.java index 7b6107a92..d4e3edaaf 100644 --- a/src/main/java/org/springframework/data/neo4j/core/PropertyFilterSupport.java +++ b/src/main/java/org/springframework/data/neo4j/core/PropertyFilterSupport.java @@ -153,8 +153,13 @@ public final class PropertyFilterSupport { break; } - addPropertiesFrom(domainType, returnedType, factory, filteredProperties, - nextProjectionPathProcessor, mappingContext); + if (projectionPathProcessor.typeInformation.getActualType().getType().equals(nextProjectionPathProcessor.typeInformation.getActualType().getType()) + || (!projectionPathProcessor.typeInformation.isCollectionLike() && !projectionPathProcessor.typeInformation.isMap() && projectionPathProcessor.typeInformation.getType().equals(nextProjectionPathProcessor.typeInformation.getType()))) { + filteredProperties.add(new PropertyFilter.ProjectedPath(propertyPath, true)); + } else { + addPropertiesFrom(domainType, returnedType, factory, filteredProperties, + nextProjectionPathProcessor, mappingContext); + } } } else { // An open projection at this place needs to get replaced with the matching (real) entity