Avoid constructing a complex failure message when there are no failures.
Discovered while I was trying to debug a problem and found out that my
breakpoint within CommandFailureUtils.describeCommandFailure was being
hit for every action.
RELNOTES: None.
@@ -129,21 +129,16 @@ abstract class AbstractSandboxSpawnRunner implements SpawnRunner {
}
}
- private final SpawnResult run(
- Spawn originalSpawn, SandboxedSpawn sandbox, Duration timeout, FileOutErr outErr)
- throws IOException, InterruptedException {
- String failureMessage;
+ private String makeFailureMessage(Spawn originalSpawn, SandboxedSpawn sandbox) {
if (sandboxOptions.sandboxDebug) {
- failureMessage =
- CommandFailureUtils.describeCommandFailure(
+ return CommandFailureUtils.describeCommandFailure(
true,
sandbox.getArguments(),
sandbox.getEnvironment(),
sandbox.getSandboxExecRoot().getPathString(),
null);
} else {
- failureMessage =
- CommandFailureUtils.describeCommandFailure(
+ return CommandFailureUtils.describeCommandFailure(
verboseFailures,
originalSpawn.getArguments(),
originalSpawn.getEnvironment(),
@@ -151,7 +146,11 @@ abstract class AbstractSandboxSpawnRunner implements SpawnRunner {
originalSpawn.getExecutionPlatform())
+ SANDBOX_DEBUG_SUGGESTION;
}
+ }
+ private final SpawnResult run(
+ Spawn originalSpawn, SandboxedSpawn sandbox, Duration timeout, FileOutErr outErr)
+ throws IOException, InterruptedException {
SubprocessBuilder subprocessBuilder = new SubprocessBuilder();
subprocessBuilder.setWorkingDirectory(sandbox.getSandboxExecRoot().getPathFile());
subprocessBuilder.setStdout(outErr.getOutputPath().getPathFile());
@@ -184,7 +183,7 @@ abstract class AbstractSandboxSpawnRunner implements SpawnRunner {
.setRunnerName(getName())
.setStatus(Status.EXECUTION_FAILED)
.setExitCode(LOCAL_EXEC_ERROR)
- .setFailureMessage(failureMessage)
+ .setFailureMessage(makeFailureMessage(originalSpawn, sandbox))
.build();
}
@@ -205,7 +204,10 @@ abstract class AbstractSandboxSpawnRunner implements SpawnRunner {
.setStatus(status)
.setExitCode(exitCode)
.setWallTime(wallTime)
- .setFailureMessage(status != Status.SUCCESS || exitCode != 0 ? failureMessage : "");
+ .setFailureMessage(
+ status != Status.SUCCESS || exitCode != 0
+ ? makeFailureMessage(originalSpawn, sandbox)
+ : "");
Path statisticsPath = sandbox.getStatisticsPath();
if (statisticsPath != null) {
