diff options
author | Janak Ramakrishnan <janakr@google.com> | 2016-03-31 18:44:21 +0000 |
---|---|---|
committer | Damien Martin-Guillerez <dmarting@google.com> | 2016-03-31 20:28:56 +0000 |
commit | 2cea5dd3b55d40109ad53ee45cf3593f7094c10b (patch) | |
tree | fb1ffaa99426afc6ebbb05b291413523bad01f4e | |
parent | 215fa84908f22345347031c2e3b388433cc2b697 (diff) |
Don't try to clean up (and potentially exit with minor IOException exit code) if we actually crashed.
--
MOS_MIGRATED_REVID=118702463
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/runtime/commands/QueryCommand.java | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/runtime/commands/QueryCommand.java b/src/main/java/com/google/devtools/build/lib/runtime/commands/QueryCommand.java index 234c03a490..520d08cb45 100644 --- a/src/main/java/com/google/devtools/build/lib/runtime/commands/QueryCommand.java +++ b/src/main/java/com/google/devtools/build/lib/runtime/commands/QueryCommand.java @@ -165,10 +165,13 @@ public final class QueryCommand implements BlazeCommand { } else { callback = new AggregateAllOutputFormatterCallback<>(); } + boolean catastrophe = true; try { callback.start(); result = queryEnv.evaluateQuery(expr, callback); + catastrophe = false; } catch (QueryException e) { + catastrophe = false; // Keep consistent with reportBuildFileError() env.getReporter() // TODO(bazel-team): this is a kludge to fix a bug observed in the wild. We should make @@ -176,6 +179,7 @@ public final class QueryCommand implements BlazeCommand { .handle(Event.error(e.getMessage() == null ? e.toString() : e.getMessage())); return ExitCode.ANALYSIS_FAILURE; } catch (InterruptedException e) { + catastrophe = false; IOException ioException = callback.getIoException(); if (ioException == null || ioException instanceof ClosedByInterruptException) { env.getReporter().handle(Event.error("query interrupted")); @@ -185,17 +189,20 @@ public final class QueryCommand implements BlazeCommand { return ExitCode.LOCAL_ENVIRONMENTAL_ERROR; } } catch (IOException e) { + catastrophe = false; env.getReporter().handle(Event.error("I/O error: " + e.getMessage())); return ExitCode.LOCAL_ENVIRONMENTAL_ERROR; } finally { - if (streamResults) { - output.flush(); - } - try { - callback.close(); - } catch (IOException e) { - env.getReporter().handle(Event.error("I/O error: " + e.getMessage())); - return ExitCode.LOCAL_ENVIRONMENTAL_ERROR; + if (!catastrophe) { + if (streamResults) { + output.flush(); + } + try { + callback.close(); + } catch (IOException e) { + env.getReporter().handle(Event.error("I/O error: " + e.getMessage())); + return ExitCode.LOCAL_ENVIRONMENTAL_ERROR; + } } } |