aboutsummaryrefslogtreecommitdiff
path: root/spark-common/src
diff options
context:
space:
mode:
Diffstat (limited to 'spark-common/src')
-rw-r--r--spark-common/src/main/java/me/lucko/spark/common/sampler/async/AsyncSampler.java21
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);
+ }
+ }
}