Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent overlogging of debug msgs in Graph impl #2813

Merged
merged 1 commit into from Oct 28, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 3 additions & 21 deletions testng-core/src/main/java/org/testng/internal/Graph.java
Expand Up @@ -21,7 +21,6 @@
* @author Cedric Beust, Aug 19, 2004
*/
public class Graph<T> {
private static final boolean m_verbose = true;
private final Map<T, Node<T>> m_nodes = Maps.newLinkedHashMap();
private List<T> m_strictlySortedNodes = null;
private final Comparator<Node<T>> comparator;
Expand Down Expand Up @@ -59,7 +58,6 @@ public void addPredecessor(T tm, T predecessor) {
throw new TestNGException("Non-existing node: " + tm);
} else {
node.addPredecessor(predecessor);
addNeighbor(tm, predecessor);
// Remove these two nodes from the independent list
initializeIndependentNodes();
m_independentNodes.remove(predecessor);
Expand All @@ -68,10 +66,6 @@ public void addPredecessor(T tm, T predecessor) {
}
}

private void addNeighbor(T tm, T predecessor) {
findNode(tm).addNeighbor(findNode(predecessor));
}

private Collection<Node<T>> getNodes() {
return m_nodes.values();
}
Expand Down Expand Up @@ -133,9 +127,7 @@ public void topologicalSort() {
}

log("=============== DONE SORTING");
if (m_verbose) {
dumpSortedNodes();
}
dumpSortedNodes();
}

private void initializeIndependentNodes() {
Expand Down Expand Up @@ -173,15 +165,11 @@ private void removeFromNodes(List<Node<T>> nodes, Node<T> node) {
}

private static void log(String s) {
if (m_verbose) {
Logger.getLogger(Graph.class).debug("[Graph] " + s);
}
log(() -> s);
}

private static void log(Supplier<String> s) {
if (m_verbose) {
Logger.getLogger(Graph.class).debug("[Graph] " + s.get());
}
Logger.getLogger(Graph.class).debug("[Graph] " + s.get());
}

private Node<T> findNodeWithNoPredecessors(List<Node<T>> nodes) {
Expand Down Expand Up @@ -253,12 +241,6 @@ public Node(T tm) {
m_object = tm;
}

private final Set<Node<T>> m_neighbors = new HashSet<>();

public void addNeighbor(Node<T> neighbor) {
m_neighbors.add(neighbor);
}

@Override
public Node<T> clone() {
Node<T> result = new Node<>(m_object);
Expand Down