aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/actions/Artifact.java
diff options
context:
space:
mode:
authorGravatar Dmitry Lomov <dslomov@google.com>2018-05-30 04:34:08 -0700
committerGravatar Copybara-Service <copybara-piper@google.com>2018-05-30 04:35:42 -0700
commit5b1ce4d5d7568ecacf02c63c30a9cc7ce7ef24d3 (patch)
treeeee571e4bf5d2dfc304084808d449febce5f2b8a /src/main/java/com/google/devtools/build/lib/actions/Artifact.java
parent1973be49ca38a17e5272e8af1d0ba6b00e442d1f (diff)
Fix `equals()` and `hashCode()` for artifacts: artifacts of different classes are not equal.
Also validate that there are no tree and file artifacts with the same exec path. Fixes #4668. Closes #5284. Change-Id: Id97c0407a476a5bfc697b4ca7b858e3d0c0f8c75 PiperOrigin-RevId: 198540425
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/actions/Artifact.java')
-rw-r--r--src/main/java/com/google/devtools/build/lib/actions/Artifact.java5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/actions/Artifact.java b/src/main/java/com/google/devtools/build/lib/actions/Artifact.java
index 95714cdc8a..f18e14f0d0 100644
--- a/src/main/java/com/google/devtools/build/lib/actions/Artifact.java
+++ b/src/main/java/com/google/devtools/build/lib/actions/Artifact.java
@@ -228,7 +228,7 @@ public class Artifact
throw new IllegalArgumentException(
"it is illegal to create an artifact with an empty execPath");
}
- this.hashCode = execPath.hashCode();
+ this.hashCode = execPath.hashCode() + this.getClass().hashCode() * 13;
this.root = root;
this.execPath = execPath;
this.rootRelativePath = rootRelativePath;
@@ -641,6 +641,9 @@ public class Artifact
if (!(other instanceof Artifact)) {
return false;
}
+ if (!getClass().equals(other.getClass())) {
+ return false;
+ }
// We don't bother to check root in the equivalence relation, because we
// assume that no root is an ancestor of another one.
Artifact that = (Artifact) other;