From 90a55a994b5f5ae5ad928052ed77351055c28945 Mon Sep 17 00:00:00 2001 From: lberki Date: Thu, 1 Aug 2019 11:24:54 -0700 Subject: [PATCH] Fix even more fallout of https://github.com/bazelbuild/bazel/commit/f7eee1edc1f8dfc6d436894db2eb672bb11bc962 . RELNOTES: None. PiperOrigin-RevId: 261161639 --- .../build/lib/actions/FileArtifactValue.java | 27 ++++++++++++++----- 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/google/devtools/build/lib/actions/FileArtifactValue.java b/src/main/java/com/google/devtools/build/lib/actions/FileArtifactValue.java index bf9476515584bd..e2c635cd2d1650 100644 --- a/src/main/java/com/google/devtools/build/lib/actions/FileArtifactValue.java +++ b/src/main/java/com/google/devtools/build/lib/actions/FileArtifactValue.java @@ -478,7 +478,9 @@ public long getModifiedTime() { @Override public String toString() { return MoreObjects.toStringHelper(this) - .add("digest", BaseEncoding.base16().lowerCase().encode(digest)) + .add( + "digest", + digest == null ? "(null)" : BaseEncoding.base16().lowerCase().encode(digest)) .add("size", size) .add("proxy", proxy) .toString(); @@ -486,6 +488,12 @@ public String toString() { @Override public boolean couldBeModifiedSince(FileArtifactValue o) { + if (digest != null && o.getDigest() != null) { + // TODO(lberki): This sometimes compares between RemoteFileArtifactValue and + // RegularFileArtifactValue. Pretty unintuitive, that. + return !Arrays.equals(digest, o.getDigest()) || getSize() != o.getSize(); + } + if (!(o instanceof RegularFileArtifactValue)) { return true; } @@ -495,11 +503,7 @@ public boolean couldBeModifiedSince(FileArtifactValue o) { return true; } - if (digest != null && lastKnown.digest != null) { - return !Arrays.equals(digest, lastKnown.digest); - } else { - return !Objects.equals(proxy, lastKnown.proxy); - } + return !Objects.equals(proxy, lastKnown.proxy); } @Override @@ -564,6 +568,17 @@ public FileContentsProxy getContentsProxy() { throw new UnsupportedOperationException(); } + @Override + public boolean couldBeModifiedSince(FileArtifactValue o) { + if (digest != null && o.getDigest() != null) { + // TODO(lberki): This sometimes compares between RemoteFileArtifactValue and + // RegularFileArtifactValue. Pretty unintuitive, that. + return !Arrays.equals(digest, o.getDigest()) || getSize() != o.getSize(); + } + + return true; + } + @Override public long getSize() { return size;