Skip to content

Commit

Permalink
Fix message generation of ActionExecutionException
Browse files Browse the repository at this point in the history
This fixes an issue introduced by commit f95b80d, which resulted in certain exception message being printed twice.

Closes bazelbuild#18243.

PiperOrigin-RevId: 527848438
Change-Id: Ic0f7a4a0e3bdf07c1c520647dbb4b41d29e05648
  • Loading branch information
fmeum authored and fweikert committed May 25, 2023
1 parent 61b3f3e commit 5afbaa1
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 57 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public ActionExecutionException(
ActionAnalysisMetadata action,
boolean catastrophe,
DetailedExitCode detailedExitCode) {
super(combineMessages(message, cause), cause);
super(message, cause);
this.action = action;
this.catastrophe = catastrophe;
this.detailedExitCode = checkNotNull(detailedExitCode);
Expand Down Expand Up @@ -96,7 +96,7 @@ public ActionExecutionException(
NestedSet<Cause> rootCauses,
boolean catastrophe,
DetailedExitCode detailedExitCode) {
super(combineMessages(message, cause), cause);
super(message, cause);
this.action = action;
this.rootCauses = rootCauses;
this.catastrophe = catastrophe;
Expand Down Expand Up @@ -203,12 +203,4 @@ public DetailedExitCode getDetailedExitCode() {
public boolean showError() {
return getMessage() != null;
}

@Nullable
private static String combineMessages(String message, @Nullable Throwable cause) {
if (cause == null || cause.getMessage() == null) {
return message;
}
return message + ": " + cause.getMessage();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1593,7 +1593,11 @@ private ActionExecutionException toActionExecutionException(
} else {
ex = new ActionExecutionException(message, cause, action, false, code);
}
printError(ex.getMessage(), action, actionOutput);
String reportMessage = ex.getMessage();
if (cause != null && cause.getMessage() != null) {
reportMessage += ": " + cause.getMessage();
}
printError(reportMessage, action, actionOutput);
return ex;
}

Expand Down

This file was deleted.

1 change: 0 additions & 1 deletion src/test/java/com/google/devtools/build/lib/actions/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ java_library(
"//src/main/java/com/google/devtools/build/lib/skyframe/serialization/testutils",
"//src/main/java/com/google/devtools/build/lib/skyframe/serialization/testutils:depsutils",
"//src/main/java/com/google/devtools/build/lib/util",
"//src/main/java/com/google/devtools/build/lib/util:detailed_exit_code",
"//src/main/java/com/google/devtools/build/lib/util:filetype",
"//src/main/java/com/google/devtools/build/lib/util:string",
"//src/main/java/com/google/devtools/build/lib/vfs",
Expand Down

0 comments on commit 5afbaa1

Please sign in to comment.