From aaf0653d0e653b11b3d4d65f570bea594fbd4663 Mon Sep 17 00:00:00 2001 From: Michael Keppler Date: Wed, 18 Sep 2024 13:27:12 +0200 Subject: [PATCH] Avoid endless recursion * Normalize path before using it as key in a cache lookup (to avoid /foo/../a to be different than /a) * stop recursion if parent model is identical to child model fixes #3809 --- .../org/eclipse/tycho/pomless/AbstractTychoMapping.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tycho-extras/tycho-pomless/src/main/java/org/eclipse/tycho/pomless/AbstractTychoMapping.java b/tycho-extras/tycho-pomless/src/main/java/org/eclipse/tycho/pomless/AbstractTychoMapping.java index 091bb7080f..31aa5dc1f9 100644 --- a/tycho-extras/tycho-pomless/src/main/java/org/eclipse/tycho/pomless/AbstractTychoMapping.java +++ b/tycho-extras/tycho-pomless/src/main/java/org/eclipse/tycho/pomless/AbstractTychoMapping.java @@ -173,7 +173,9 @@ protected Path getRealArtifactFile(Path polyglotArtifactFile) { return polyglotArtifactFile; } - protected synchronized ParentModel findParent(Path projectRoot, Map projectOptions) throws IOException { + protected synchronized ParentModel findParent(Path projectRootIn, Map projectOptions) + throws IOException { + var projectRoot = projectRootIn.normalize(); ParentModel cached = parentModelCache.get(projectRoot); if (cached != null) { return cached; @@ -371,7 +373,7 @@ private boolean modelHasProperty(String property, Model model, Path projectRoot) try { ParentModel parent = findParent(projectRoot.getParent(), Map.of()); Model parentModel = parent.parentModel(); - if (parentModel != null) { + if (parentModel != null && parentModel != model) { return modelHasProperty(property, parentModel, projectRoot.resolve(parent.parentReference().getRelativePath())); }