You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by ga...@apache.org on 2009/04/30 05:47:30 UTC
svn commit: r770051 -
/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/BlueprintContextImpl.java
Author: gawor
Date: Thu Apr 30 03:47:30 2009
New Revision: 770051
URL: http://svn.apache.org/viewvc?rev=770051&view=rev
Log:
prevent StackOverflowError in case there are circular dependencies
Modified:
geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/BlueprintContextImpl.java
Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/BlueprintContextImpl.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/BlueprintContextImpl.java?rev=770051&r1=770050&r2=770051&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/BlueprintContextImpl.java (original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/BlueprintContextImpl.java Thu Apr 30 03:47:30 2009
@@ -24,6 +24,7 @@
import java.util.Collection;
import java.util.Collections;
import java.util.Dictionary;
+import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -260,7 +261,7 @@
if (r instanceof SatisfiableRecipe) {
recipes.add((SatisfiableRecipe) r);
}
- getSatisfiableDependencies(r, recipes);
+ getSatisfiableDependencies(r, recipes, new HashSet<Recipe>());
if (!recipes.isEmpty()) {
satisfiables.put(name, recipes);
}
@@ -276,12 +277,15 @@
return satisfiables;
}
- private void getSatisfiableDependencies(Recipe r, List<SatisfiableRecipe> recipes) {
- for (Recipe dep : r.getNestedRecipes()) {
- if (dep instanceof SatisfiableRecipe) {
- recipes.add((SatisfiableRecipe) dep);
+ private void getSatisfiableDependencies(Recipe r, List<SatisfiableRecipe> recipes, Set<Recipe> visited) {
+ if (!visited.contains(r)) {
+ visited.add(r);
+ for (Recipe dep : r.getNestedRecipes()) {
+ if (dep instanceof SatisfiableRecipe) {
+ recipes.add((SatisfiableRecipe) dep);
+ }
+ getSatisfiableDependencies(dep, recipes, visited);
}
- getSatisfiableDependencies(dep, recipes);
}
}