From be485db831137c2af5cad58d90c5c857e5bac6e4 Mon Sep 17 00:00:00 2001 From: dteller Date: Thu, 11 May 2023 09:15:13 -0400 Subject: [PATCH] fix: prevent OOM when processing large gradle project with many dependencies --- src/main/java/com/jfrog/GradleDependencyTreeUtils.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/jfrog/GradleDependencyTreeUtils.java b/src/main/java/com/jfrog/GradleDependencyTreeUtils.java index 1e21cd5..5ef7085 100644 --- a/src/main/java/com/jfrog/GradleDependencyTreeUtils.java +++ b/src/main/java/com/jfrog/GradleDependencyTreeUtils.java @@ -76,6 +76,9 @@ private static void addUnresolvedConfiguration(GradleDependencyTree node, Config private static void populateTree(GradleDependencyTree node, String configurationName, DependencyResult dependency, Set addedChildren) { GradleDependencyTree child = new GradleDependencyTree(configurationName); if (dependency instanceof UnresolvedDependencyResult) { + if (!addedChildren.add(dependency.getRequested().getDisplayName())) { + return; + } child.setUnresolved(true); addChild(node, dependency.getRequested().getDisplayName(), child); return; @@ -91,7 +94,7 @@ private static void populateTree(GradleDependencyTree node, String configuration } addChild(node, moduleVersion.toString(), child); for (DependencyResult dependencyResult : resolvedDependency.getSelected().getDependencies()) { - populateTree(child, configurationName, dependencyResult, new HashSet<>(addedChildren)); + populateTree(child, configurationName, dependencyResult, addedChildren); } }