aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/actions/AbstractAction.java
diff options
context:
space:
mode:
authorGravatar Janak Ramakrishnan <janakr@google.com>2015-03-18 21:59:16 +0000
committerGravatar Han-Wen Nienhuys <hanwen@google.com>2015-03-20 14:32:58 +0000
commita7c84b508c3c0a31e589de0de006b6cb9b7fd515 (patch)
tree11338ff270a4d9a0b319ab10dfbfa97244ac4d4f /src/main/java/com/google/devtools/build/lib/actions/AbstractAction.java
parentbedbc441984d8a8dbf623b9a7669a4692eeeefff (diff)
Delay updating inputs of an action when processing the action cache until it is known that the action is a cache hit.
This adds momentary memory overhead when checking the action cache, but should prevent a host of potential errors. Note that this cl assumes that an action that discovers its inputs does *not* take the names of its inputs into account when calculating its key, which is already stated as part of the javadoc of Action#getKey. -- MOS_MIGRATED_REVID=88971626
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/actions/AbstractAction.java')
-rw-r--r--src/main/java/com/google/devtools/build/lib/actions/AbstractAction.java15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/actions/AbstractAction.java b/src/main/java/com/google/devtools/build/lib/actions/AbstractAction.java
index 09457474bd..324d0b4608 100644
--- a/src/main/java/com/google/devtools/build/lib/actions/AbstractAction.java
+++ b/src/main/java/com/google/devtools/build/lib/actions/AbstractAction.java
@@ -36,6 +36,8 @@ import com.google.devtools.build.lib.vfs.Symlinks;
import java.io.IOException;
import java.util.Collection;
+import javax.annotation.Nullable;
+
/**
* Abstract implementation of Action which implements basic functionality: the
* inputs, outputs, and toString method. Both input and output sets are
@@ -98,13 +100,20 @@ public abstract class AbstractAction implements Action {
+ " since it does not discover inputs");
}
+ @Nullable
@Override
- public boolean updateInputsFromCache(ArtifactResolver artifactResolver,
+ public Iterable<Artifact> resolveInputsFromCache(ArtifactResolver artifactResolver,
PackageRootResolver resolver, Collection<PathFragment> inputPaths) {
throw new IllegalStateException(
"Method must be overridden for actions that may have unknown inputs.");
}
+ @Override
+ public void updateInputs(Iterable<Artifact> inputs) {
+ throw new IllegalStateException(
+ "Method must be overridden for actions that may have unknown inputs.");
+ }
+
/**
* Should only be overridden by actions that need to optionally insert inputs. Actions that
* discover their inputs should use {@link #setInputs} to set the new iterable of inputs when they
@@ -119,8 +128,8 @@ public abstract class AbstractAction implements Action {
* Set the inputs of the action. May only be used by an action that {@link #discoversInputs()}.
* The iterable passed in is automatically made immutable.
*/
- public void setInputs(Iterable<Artifact> inputs) {
- Preconditions.checkState(discoversInputs());
+ protected void setInputs(Iterable<Artifact> inputs) {
+ Preconditions.checkState(discoversInputs(), this);
this.inputs = CollectionUtils.makeImmutable(inputs);
cachedInputCount = -1;
}