From b276a722c4975578a249eb1b7908324f979544e0 Mon Sep 17 00:00:00 2001 From: Ola Rozenfeld Date: Thu, 15 Sep 2016 13:50:57 +0000 Subject: Cosmetic changes to the remote execution proto, and fixing a minor bug in ContentDigests function. -- MOS_MIGRATED_REVID=133256094 --- .../google/devtools/build/lib/remote/ContentDigests.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/main/java/com/google/devtools') 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) { -- cgit v1.2.3