diff options
-rw-r--r-- | spark-common/src/main/java/me/lucko/spark/sampler/Sampler.java | 3 | ||||
-rw-r--r-- | spark-common/src/main/java/me/lucko/spark/sampler/ThreadDumper.java | 13 |
2 files changed, 7 insertions, 9 deletions
diff --git a/spark-common/src/main/java/me/lucko/spark/sampler/Sampler.java b/spark-common/src/main/java/me/lucko/spark/sampler/Sampler.java index d78b3fd..3a9a271 100644 --- a/spark-common/src/main/java/me/lucko/spark/sampler/Sampler.java +++ b/spark-common/src/main/java/me/lucko/spark/sampler/Sampler.java @@ -23,7 +23,6 @@ package me.lucko.spark.sampler; import com.google.common.util.concurrent.ThreadFactoryBuilder; import com.google.gson.stream.JsonWriter; - import me.lucko.spark.sampler.aggregator.DataAggregator; import me.lucko.spark.sampler.aggregator.SimpleDataAggregator; import me.lucko.spark.sampler.aggregator.TickedDataAggregator; @@ -130,7 +129,7 @@ public class Sampler implements Runnable { return; } - Iterable<ThreadInfo> threadDumps = this.threadDumper.dumpThreads(this.threadBean); + ThreadInfo[] threadDumps = this.threadDumper.dumpThreads(this.threadBean); for (ThreadInfo threadInfo : threadDumps) { String threadName = threadInfo.getThreadName(); StackTraceElement[] stack = threadInfo.getStackTrace(); diff --git a/spark-common/src/main/java/me/lucko/spark/sampler/ThreadDumper.java b/spark-common/src/main/java/me/lucko/spark/sampler/ThreadDumper.java index 38cdd36..5b68eaf 100644 --- a/spark-common/src/main/java/me/lucko/spark/sampler/ThreadDumper.java +++ b/spark-common/src/main/java/me/lucko/spark/sampler/ThreadDumper.java @@ -25,7 +25,6 @@ import me.lucko.spark.util.ThreadFinder; import java.lang.management.ThreadInfo; import java.lang.management.ThreadMXBean; -import java.util.Arrays; import java.util.HashMap; import java.util.Map; import java.util.Objects; @@ -47,12 +46,12 @@ public interface ThreadDumper { * @param threadBean the thread bean instance to obtain the data from * @return an array of generated thread info instances */ - Iterable<ThreadInfo> dumpThreads(ThreadMXBean threadBean); + ThreadInfo[] dumpThreads(ThreadMXBean threadBean); /** * Implementation of {@link ThreadDumper} that generates data for all threads. */ - ThreadDumper ALL = threadBean -> Arrays.asList(threadBean.dumpAllThreads(false, false)); + ThreadDumper ALL = threadBean -> threadBean.dumpAllThreads(false, false); /** * Implementation of {@link ThreadDumper} that generates data for a specific set of threads. @@ -74,8 +73,8 @@ public interface ThreadDumper { } @Override - public Iterable<ThreadInfo> dumpThreads(ThreadMXBean threadBean) { - return Arrays.asList(threadBean.getThreadInfo(this.ids, Integer.MAX_VALUE)); + public ThreadInfo[] dumpThreads(ThreadMXBean threadBean) { + return threadBean.getThreadInfo(this.ids, Integer.MAX_VALUE); } } @@ -101,7 +100,7 @@ public interface ThreadDumper { } @Override - public Iterable<ThreadInfo> dumpThreads(ThreadMXBean threadBean) { + public ThreadInfo[] dumpThreads(ThreadMXBean threadBean) { return this.threadFinder.getThreads() .filter(thread -> { Boolean result = this.cache.get(thread.getId()); @@ -120,7 +119,7 @@ public interface ThreadDumper { }) .map(thread -> threadBean.getThreadInfo(thread.getId())) .filter(Objects::nonNull) - .collect(Collectors.toList()); + .toArray(ThreadInfo[]::new); } } |