aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib
diff options
context:
space:
mode:
authorGravatar Liam Miller-Cushon <cushon@google.com>2017-02-01 17:33:50 +0000
committerGravatar Yun Peng <pcloudy@google.com>2017-02-02 09:58:01 +0000
commite1169a68dcd0e5d8837f15f1fc97949c4fbeb291 (patch)
tree2a3e5b08fd54213f288d4981f7a7a07cc0d3b0a1 /src/main/java/com/google/devtools/build/lib
parent47bde4012eb05674e2b100eb985de79db86573f4 (diff)
Fix a NPE in crash reporting
if the product name is null, which is the case for some integration tests. -- PiperOrigin-RevId: 146252594 MOS_MIGRATED_REVID=146252594
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib')
-rw-r--r--src/main/java/com/google/devtools/build/lib/runtime/BugReport.java16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/runtime/BugReport.java b/src/main/java/com/google/devtools/build/lib/runtime/BugReport.java
index d0470364d9..2838aaf93b 100644
--- a/src/main/java/com/google/devtools/build/lib/runtime/BugReport.java
+++ b/src/main/java/com/google/devtools/build/lib/runtime/BugReport.java
@@ -53,6 +53,10 @@ public abstract class BugReport {
runtime = newRuntime;
}
+ private static String getProductName() {
+ return runtime != null ? runtime.getProductName() : "<unknown>";
+ }
+
/**
* Logs the unhandled exception with a special prefix signifying that this was a crash.
*
@@ -72,7 +76,7 @@ public abstract class BugReport {
private static void logCrash(Throwable throwable, String... args) {
BugReport.sendBugReport(throwable, Arrays.asList(args));
BugReport.printBug(OutErr.SYSTEM_OUT_ERR, throwable);
- System.err.println(runtime.getProductName() + " crash in async thread:");
+ System.err.println(getProductName() + " crash in async thread:");
throwable.printStackTrace();
}
@@ -110,9 +114,9 @@ public abstract class BugReport {
} catch (Throwable t) {
System.err.println(
"An crash occurred while "
- + runtime.getProductName()
+ + getProductName()
+ " was trying to handle a crash! Please file a bug against "
- + runtime.getProductName()
+ + getProductName()
+ " and include the information below.");
System.err.println("Original uncaught exception:");
@@ -136,7 +140,7 @@ public abstract class BugReport {
PrintStream err = new PrintStream(outErr.getErrorStream());
e.printStackTrace(err);
err.flush();
- LOG.log(Level.SEVERE, runtime.getProductName() + " crashed", e);
+ LOG.log(Level.SEVERE, getProductName() + " crashed", e);
}
/**
@@ -148,7 +152,7 @@ public abstract class BugReport {
public static void printBug(OutErr outErr, Throwable e) {
if (e instanceof OutOfMemoryError) {
outErr.printErr(
- e.getMessage() + "\n\n" + runtime.getProductName() + " ran out of memory and crashed.\n");
+ e.getMessage() + "\n\n" + getProductName() + " ran out of memory and crashed.\n");
} else {
printThrowableTo(outErr, e);
}
@@ -179,7 +183,7 @@ public abstract class BugReport {
private static void logException(Throwable exception, List<String> args, String... values) {
// The preamble is used in the crash watcher, so don't change it
// unless you know what you're doing.
- String preamble = runtime.getProductName()
+ String preamble = getProductName()
+ (exception instanceof OutOfMemoryError ? " OOMError: " : " crashed with args: ");
LoggingUtil.logToRemote(Level.SEVERE, preamble + Joiner.on(' ').join(args), exception,