diff options
author | 2016-11-17 22:37:33 +0000 | |
---|---|---|
committer | 2016-11-18 10:54:37 +0000 | |
commit | a2565aa2b33273972554325a02f2a9bc30a15c62 (patch) | |
tree | 3fdb183d74305464a1d59db202186689669e4bad /src/main/java/com/google/devtools/build/lib/query2/output | |
parent | 621212d09e000773c7c63b7bf7ce0a4e89aad29b (diff) |
Introduce a failFast mode to OutputFormatterCallback#close.
--
MOS_MIGRATED_REVID=139508838
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/query2/output')
3 files changed, 25 insertions, 17 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/query2/output/OutputFormatter.java b/src/main/java/com/google/devtools/build/lib/query2/output/OutputFormatter.java index f68e851f2f..7b053163cc 100644 --- a/src/main/java/com/google/devtools/build/lib/query2/output/OutputFormatter.java +++ b/src/main/java/com/google/devtools/build/lib/query2/output/OutputFormatter.java @@ -244,8 +244,10 @@ public abstract class OutputFormatter implements Serializable { } @Override - public void close() throws IOException { - flushAndCheckError(printStream); + public void close(boolean failFast) throws IOException { + if (!failFast) { + flushAndCheckError(printStream); + } } } @@ -329,12 +331,14 @@ public abstract class OutputFormatter implements Serializable { } @Override - public void close() throws IOException { - final String lineTerm = options.getLineTerminator(); - for (String packageName : packageNames) { - printStream.printf("%s%s", packageName, lineTerm); + public void close(boolean failFast) throws IOException { + if (!failFast) { + final String lineTerm = options.getLineTerminator(); + for (String packageName : packageNames) { + printStream.printf("%s%s", packageName, lineTerm); + } } - super.close(); + super.close(failFast); } }; } diff --git a/src/main/java/com/google/devtools/build/lib/query2/output/ProtoOutputFormatter.java b/src/main/java/com/google/devtools/build/lib/query2/output/ProtoOutputFormatter.java index e291129f62..317888d073 100644 --- a/src/main/java/com/google/devtools/build/lib/query2/output/ProtoOutputFormatter.java +++ b/src/main/java/com/google/devtools/build/lib/query2/output/ProtoOutputFormatter.java @@ -121,8 +121,10 @@ public class ProtoOutputFormatter extends AbstractUnorderedFormatter { } @Override - public void close() throws IOException { - queryResult.build().writeTo(out); + public void close(boolean failFast) throws IOException { + if (!failFast) { + queryResult.build().writeTo(out); + } } }; } diff --git a/src/main/java/com/google/devtools/build/lib/query2/output/XmlOutputFormatter.java b/src/main/java/com/google/devtools/build/lib/query2/output/XmlOutputFormatter.java index 6671e0214f..193ef18cf7 100644 --- a/src/main/java/com/google/devtools/build/lib/query2/output/XmlOutputFormatter.java +++ b/src/main/java/com/google/devtools/build/lib/query2/output/XmlOutputFormatter.java @@ -99,14 +99,16 @@ class XmlOutputFormatter extends AbstractUnorderedFormatter { } @Override - public void close() throws IOException { - try { - Transformer transformer = TransformerFactory.newInstance().newTransformer(); - transformer.setOutputProperty(OutputKeys.INDENT, "yes"); - transformer.transform(new DOMSource(doc), new StreamResult(out)); - } catch (TransformerFactoryConfigurationError | TransformerException e) { - // This shouldn't be possible: all the configuration is hard-coded. - throw new IllegalStateException("XML output failed", e); + public void close(boolean failFast) throws IOException { + if (!failFast) { + try { + Transformer transformer = TransformerFactory.newInstance().newTransformer(); + transformer.setOutputProperty(OutputKeys.INDENT, "yes"); + transformer.transform(new DOMSource(doc), new StreamResult(out)); + } catch (TransformerFactoryConfigurationError | TransformerException e) { + // This shouldn't be possible: all the configuration is hard-coded. + throw new IllegalStateException("XML output failed", e); + } } } }; |