diff options
author | Luck <git@lucko.me> | 2022-09-04 10:53:06 +0100 |
---|---|---|
committer | Luck <git@lucko.me> | 2022-09-04 10:53:06 +0100 |
commit | 618230b958d7822985e2702cd9528f1b4567e59c (patch) | |
tree | c46f19f0d10d483c36ed929ce990b893a8f17756 /spark-common/src/main/java/me/lucko/spark | |
parent | 7dce92ac6f577e04b99a1da555edfbc801efa049 (diff) | |
download | spark-618230b958d7822985e2702cd9528f1b4567e59c.tar.gz spark-618230b958d7822985e2702cd9528f1b4567e59c.tar.bz2 spark-618230b958d7822985e2702cd9528f1b4567e59c.zip |
Improve debug output when JFR parsing fails
Diffstat (limited to 'spark-common/src/main/java/me/lucko/spark')
-rw-r--r-- | spark-common/src/main/java/me/lucko/spark/common/sampler/async/AsyncSampler.java | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/spark-common/src/main/java/me/lucko/spark/common/sampler/async/AsyncSampler.java b/spark-common/src/main/java/me/lucko/spark/common/sampler/async/AsyncSampler.java index d8288da..dae3852 100644 --- a/spark-common/src/main/java/me/lucko/spark/common/sampler/async/AsyncSampler.java +++ b/spark-common/src/main/java/me/lucko/spark/common/sampler/async/AsyncSampler.java @@ -185,8 +185,19 @@ public class AsyncSampler extends AbstractSampler { // read the jfr file produced by async-profiler try (JfrReader reader = new JfrReader(this.outputFile)) { readSegments(reader, threadFilter); - } catch (IOException e) { - throw new RuntimeException("Read error", e); + } catch (Exception e) { + boolean fileExists; + try { + fileExists = Files.exists(this.outputFile) && Files.size(this.outputFile) != 0; + } catch (IOException ex) { + fileExists = false; + } + + if (fileExists) { + throw new JfrParsingException("Error parsing JFR data from profiler output", e); + } else { + throw new JfrParsingException("Error parsing JFR data from profiler output - file " + this.outputFile + " does not exist!", e); + } } // delete the output file after reading @@ -268,4 +279,10 @@ public class AsyncSampler extends AbstractSampler { reader.stackFrames.put(methodId, result); return result; } + + private static final class JfrParsingException extends RuntimeException { + public JfrParsingException(String message, Throwable cause) { + super(message, cause); + } + } } |