aboutsummaryrefslogtreecommitdiff
path: root/spark-common/src/main/java/me
diff options
context:
space:
mode:
Diffstat (limited to 'spark-common/src/main/java/me')
-rw-r--r--spark-common/src/main/java/me/lucko/spark/common/sampler/source/ClassSourceLookup.java13
1 files changed, 6 insertions, 7 deletions
diff --git a/spark-common/src/main/java/me/lucko/spark/common/sampler/source/ClassSourceLookup.java b/spark-common/src/main/java/me/lucko/spark/common/sampler/source/ClassSourceLookup.java
index 66b41d2..ab63c00 100644
--- a/spark-common/src/main/java/me/lucko/spark/common/sampler/source/ClassSourceLookup.java
+++ b/spark-common/src/main/java/me/lucko/spark/common/sampler/source/ClassSourceLookup.java
@@ -36,10 +36,12 @@ import java.nio.file.Path;
import java.nio.file.Paths;
import java.security.CodeSource;
import java.security.ProtectionDomain;
+import java.util.ArrayDeque;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
+import java.util.Queue;
import java.util.function.Function;
import java.util.stream.Collectors;
@@ -265,8 +267,10 @@ public interface ClassSourceLookup {
@Override
public void visit(ThreadNode node) {
- for (StackTraceNode child : node.getChildren()) {
- visitStackNode(child);
+ Queue<StackTraceNode> queue = new ArrayDeque<>(node.getChildren());
+ for (StackTraceNode n = queue.poll(); n != null; n = queue.poll()) {
+ visitStackNode(n);
+ queue.addAll(n.getChildren());
}
}
@@ -288,11 +292,6 @@ public interface ClassSourceLookup {
MethodCallByLine methodCall = new MethodCallByLine(node.getClassName(), node.getMethodName(), node.getLineNumber());
this.lineSources.computeIfAbsent(methodCall, this.lookup::identify);
}
-
- // recursively
- for (StackTraceNode child : node.getChildren()) {
- visitStackNode(child);
- }
}
@Override