aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build
diff options
context:
space:
mode:
authorGravatar Eric Fellheimer <felly@google.com>2015-04-20 18:50:16 +0000
committerGravatar Laszlo Csomor <laszlocsomor@google.com>2015-04-21 10:57:43 +0000
commitdedda49b582bd18e461448e40c04a6ff091ccff9 (patch)
tree4a211999f833dfe6a8974e82514fbbaa4f935499 /src/main/java/com/google/devtools/build
parenta3ac202ec114c092221b296a2695d0aadd50031f (diff)
Add a clear() method to FileOutErr.
-- MOS_MIGRATED_REVID=91605508
Diffstat (limited to 'src/main/java/com/google/devtools/build')
-rw-r--r--src/main/java/com/google/devtools/build/lib/skyframe/SkyframeActionExecutor.java1
-rw-r--r--src/main/java/com/google/devtools/build/lib/util/io/FileOutErr.java33
2 files changed, 33 insertions, 1 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeActionExecutor.java b/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeActionExecutor.java
index d4361aedff..4000d0b15f 100644
--- a/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeActionExecutor.java
+++ b/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeActionExecutor.java
@@ -445,7 +445,6 @@ public final class SkyframeActionExecutor {
ActionExecutionContext constructActionExecutionContext(
PerActionFileCache graphFileCache, MetadataHandler metadataHandler,
Map<Artifact, Collection<Artifact>> expandedInputMiddlemen) {
- // TODO(bazel-team): this should be closed explicitly somewhere.
FileOutErr fileOutErr = actionLogBufferPathGenerator.generate();
return new ActionExecutionContext(
executorEngine,
diff --git a/src/main/java/com/google/devtools/build/lib/util/io/FileOutErr.java b/src/main/java/com/google/devtools/build/lib/util/io/FileOutErr.java
index 4f9aecfbd1..de1087957b 100644
--- a/src/main/java/com/google/devtools/build/lib/util/io/FileOutErr.java
+++ b/src/main/java/com/google/devtools/build/lib/util/io/FileOutErr.java
@@ -34,6 +34,8 @@ import java.io.PrintStream;
*
* You should not use this object from multiple different threads.
*/
+// Note that it should be safe to treat the Output and Error streams within a FileOutErr each as
+// individually ThreadCompatible.
@ThreadSafety.ThreadCompatible
public class FileOutErr extends OutErr {
@@ -137,6 +139,21 @@ public class FileOutErr extends OutErr {
}
/**
+ * Closes and deletes the error stream.
+ */
+ public void clearErr() throws IOException {
+ getFileErrorStream().clear();
+ }
+
+ /**
+ * Closes and deletes the out stream.
+ */
+ public void clearOut() throws IOException {
+ getFileOutputStream().clear();
+ }
+
+
+ /**
* Writes the captured out content to the given output stream,
* avoiding keeping the entire contents in memory.
*/
@@ -193,6 +210,11 @@ public class FileOutErr extends OutErr {
* avoiding keeping the entire contents in memory.
*/
abstract void dumpOut(OutputStream out);
+
+ /**
+ * Closes and delets the output.
+ */
+ abstract void clear() throws IOException;
}
/**
@@ -229,6 +251,10 @@ public class FileOutErr extends OutErr {
return;
}
+ @Override
+ public void clear() {
+ }
+
@Override
public void write(byte[] b, int off, int len) {
@@ -292,6 +318,13 @@ public class FileOutErr extends OutErr {
return outputStream != null;
}
+ @Override
+ public synchronized void clear() throws IOException {
+ close();
+ outputStream = null;
+ outputFile.delete();
+ }
+
/**
* Called whenever the FileRecordingOutputStream finds an error.
*/