From e52ea7dbac9df3d610aef2ab3924fa9410d167e3 Mon Sep 17 00:00:00 2001 From: Luck Date: Wed, 16 Nov 2022 21:41:04 +0000 Subject: Fix exception from zero thread id (#262) --- .../java/me/lucko/spark/common/sampler/async/AsyncProfilerJob.java | 2 +- .../main/java/me/lucko/spark/common/sampler/async/jfr/JfrReader.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'spark-common/src/main/java/me/lucko/spark/common') diff --git a/spark-common/src/main/java/me/lucko/spark/common/sampler/async/AsyncProfilerJob.java b/spark-common/src/main/java/me/lucko/spark/common/sampler/async/AsyncProfilerJob.java index 1310e97..db1808c 100644 --- a/spark-common/src/main/java/me/lucko/spark/common/sampler/async/AsyncProfilerJob.java +++ b/spark-common/src/main/java/me/lucko/spark/common/sampler/async/AsyncProfilerJob.java @@ -249,7 +249,7 @@ public class AsyncProfilerJob { duration = TimeUnit.NANOSECONDS.toMicros(sample.time - samples.get(i - 1).time); } - String threadName = reader.threads.get(sample.tid); + String threadName = reader.threads.get((long) sample.tid); if (threadName == null) { continue; } diff --git a/spark-common/src/main/java/me/lucko/spark/common/sampler/async/jfr/JfrReader.java b/spark-common/src/main/java/me/lucko/spark/common/sampler/async/jfr/JfrReader.java index e0cc4e9..ea4985e 100644 --- a/spark-common/src/main/java/me/lucko/spark/common/sampler/async/jfr/JfrReader.java +++ b/spark-common/src/main/java/me/lucko/spark/common/sampler/async/jfr/JfrReader.java @@ -51,7 +51,7 @@ public class JfrReader implements Closeable { public final Dictionary types = new Dictionary<>(); public final Map typesByName = new HashMap<>(); - public final Dictionary threads = new Dictionary<>(); + public final Map threads = new HashMap<>(); // spark public final Dictionary classes = new Dictionary<>(); public final Dictionary symbols = new Dictionary<>(); public final Dictionary methods = new Dictionary<>(); @@ -324,7 +324,7 @@ public class JfrReader implements Closeable { } private void readThreads(boolean hasGroup) { - int count = threads.preallocate(getVarint()); + int count = getVarint(); //threads.preallocate(getVarint()); for (int i = 0; i < count; i++) { long id = getVarlong(); String osName = getString(); -- cgit