Skip to content

Commit

Permalink
Prevent StackOverflowError in FlowNode#getParents()
Browse files Browse the repository at this point in the history
Co-authored-by: Victor Martinez <[email protected]>
  • Loading branch information
cyrille-leclerc and v1v authored Nov 2, 2021
1 parent a842ed5 commit c0bd22c
Showing 1 changed file with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@
import javax.annotation.Nonnull;
import javax.annotation.concurrent.Immutable;
import javax.inject.Inject;
import java.util.*;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.logging.Level;
Expand Down Expand Up @@ -147,7 +151,13 @@ public void buildListOfAncestors(@Nonnull FlowNode flowNode, @Nonnull List<FlowN
flowNode = startNode;
}
for (FlowNode parentNode : flowNode.getParents()) {
buildListOfAncestors(parentNode, parents);
if (flowNode.equals(parentNode)) {
LOGGER.log(Level.INFO, "buildListOfAncestors(" + flowNode + "): skip parentFlowNode as it is the current node"); // TODO change message to Level.FINE once the cause is understood
} else if (parents.contains(parentNode)) {
LOGGER.log(Level.INFO, "buildListOfAncestors(" + flowNode + "): skip already added " + parentNode); // TODO can we remove this check once the cause is understood?
} else {
buildListOfAncestors(parentNode, parents);
}
}
}

Expand Down

0 comments on commit c0bd22c

Please sign in to comment.