aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/remote
diff options
context:
space:
mode:
authorGravatar Ola Rozenfeld <olaola@google.com>2016-09-15 13:50:57 +0000
committerGravatar Dmitry Lomov <dslomov@google.com>2016-09-15 15:43:07 +0000
commitb276a722c4975578a249eb1b7908324f979544e0 (patch)
tree2850a138159353b9ca5a7512b8334aed1790554e /src/main/java/com/google/devtools/build/lib/remote
parentcd708c3e68256ada53ed2a477a66621aad106e0d (diff)
Cosmetic changes to the remote execution proto, and fixing a minor bug in
ContentDigests function. -- MOS_MIGRATED_REVID=133256094
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/remote')
-rw-r--r--src/main/java/com/google/devtools/build/lib/remote/ContentDigests.java14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/remote/ContentDigests.java b/src/main/java/com/google/devtools/build/lib/remote/ContentDigests.java
index b9a653a125..2a7b794201 100644
--- a/src/main/java/com/google/devtools/build/lib/remote/ContentDigests.java
+++ b/src/main/java/com/google/devtools/build/lib/remote/ContentDigests.java
@@ -41,17 +41,15 @@ public final class ContentDigests {
/**
* Computes a digest of the given proto message. Currently, we simply rely on message output as
* bytes, but this implementation relies on the stability of the proto encoding, in particular
- * between different platforms and languages.
- * TODO(olaola): upgrade to a better implementation!
+ * between different platforms and languages. TODO(olaola): upgrade to a better implementation!
*/
public static ContentDigest computeDigest(Message message) {
return computeDigest(message.toByteArray());
}
/**
- * A special type of ContentDigest that is used only as a remote action cache key.
- * This is a separate type in order to prevent accidentally using other ContentDigests
- * as action keys.
+ * A special type of ContentDigest that is used only as a remote action cache key. This is a
+ * separate type in order to prevent accidentally using other ContentDigests as action keys.
*/
public static final class ActionKey {
private final ContentDigest digest;
@@ -68,7 +66,7 @@ public final class ContentDigests {
public static ActionKey computeActionKey(Action action) {
return new ActionKey(computeDigest(action));
}
-
+
public static ContentDigest buildDigest(byte[] digest, long size) {
ContentDigest.Builder b = ContentDigest.newBuilder();
b.setDigest(ByteString.copyFrom(digest)).setSizeBytes(size);
@@ -76,7 +74,9 @@ public final class ContentDigests {
}
public static String toHexString(ContentDigest digest) {
- return HashCode.fromBytes(digest.getDigest().toByteArray()).toString();
+ return digest.getSizeBytes() > 0
+ ? HashCode.fromBytes(digest.getDigest().toByteArray()).toString()
+ : "";
}
public static String toString(ContentDigest digest) {