Explicitly document the state transition on MetadataHandler
The ActionMetadataHandler does an explicit state transition on
discardOutputMetadata. Before the call, it may be used for action cache
checking, and after the call it may be updated with execution results.
Several of the methods now throw if they're used incorrectly, so I had to
refactor the control flow in ActionExecutionFunction to correctly call
discardOutputMetadata on the MetadataHandler in all cases. I discovered a
resource leak (of FileOutErr) in IncludeParseFunction while I was at it, so
I plugged that as well.
One step towards #1525.
PiperOrigin-RevId: 152363982
diff --git a/src/main/java/com/google/devtools/build/lib/actions/ActionExecutionContext.java b/src/main/java/com/google/devtools/build/lib/actions/ActionExecutionContext.java
index 09cf176..e8762ef 100644
--- a/src/main/java/com/google/devtools/build/lib/actions/ActionExecutionContext.java
+++ b/src/main/java/com/google/devtools/build/lib/actions/ActionExecutionContext.java
@@ -21,13 +21,15 @@
import com.google.devtools.build.lib.util.io.FileOutErr;
import com.google.devtools.build.skyframe.SkyFunction;
import com.google.devtools.build.skyframe.SkyFunction.Environment;
+import java.io.Closeable;
+import java.io.IOException;
import java.util.Map;
import javax.annotation.Nullable;
/**
* A class that groups services in the scope of the action. Like the FileOutErr object.
*/
-public class ActionExecutionContext {
+public class ActionExecutionContext implements Closeable {
private final Executor executor;
private final ActionInputFileCache actionInputFileCache;
@@ -135,6 +137,11 @@
return Preconditions.checkNotNull(env);
}
+ @Override
+ public void close() throws IOException {
+ fileOutErr.close();
+ }
+
/**
* Allows us to create a new context that overrides the FileOutErr with another one. This is
* useful for muting the output for example.