aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar Googler <noreply@google.com>2017-03-22 21:45:25 +0000
committerGravatar Yue Gan <yueg@google.com>2017-03-23 09:50:06 +0000
commita2248b8e553bbcd346d8cf03f5f81d9af3c947f2 (patch)
tree4c4955979e7437e9f6c6b10c3a915df32e890ee5 /src
parent09b59577695b6a305b33b2d7284aefc84617901b (diff)
Adding a more descriptive error message to ConcurrentMapActionCache
-- PiperOrigin-RevId: 150930281 MOS_MIGRATED_REVID=150930281
Diffstat (limited to 'src')
-rw-r--r--src/main/java/com/google/devtools/build/lib/remote/ConcurrentMapActionCache.java11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/remote/ConcurrentMapActionCache.java b/src/main/java/com/google/devtools/build/lib/remote/ConcurrentMapActionCache.java
index 27582bf9e8..45b44741df 100644
--- a/src/main/java/com/google/devtools/build/lib/remote/ConcurrentMapActionCache.java
+++ b/src/main/java/com/google/devtools/build/lib/remote/ConcurrentMapActionCache.java
@@ -140,10 +140,17 @@ public final class ConcurrentMapActionCache implements RemoteActionCache {
return ImmutableList.copyOf(digests);
}
+ private void checkBlobSize(long blobSizeKBytes, String type) {
+ Preconditions.checkArgument(
+ blobSizeKBytes < MAX_MEMORY_KBYTES,
+ type + ": maximum blob size exceeded: %sK > %sK.",
+ blobSizeKBytes, MAX_MEMORY_KBYTES);
+ }
+
@Override
public ContentDigest uploadBlob(byte[] blob) throws InterruptedException {
int blobSizeKBytes = blob.length / 1024;
- Preconditions.checkArgument(blobSizeKBytes < MAX_MEMORY_KBYTES);
+ checkBlobSize(blobSizeKBytes, "Upload");
ContentDigest digest = ContentDigests.computeDigest(blob);
uploadMemoryAvailable.acquire(blobSizeKBytes);
try {
@@ -160,7 +167,7 @@ public final class ConcurrentMapActionCache implements RemoteActionCache {
return new byte[0];
}
// This unconditionally downloads the whole blob into memory!
- Preconditions.checkArgument((int) (digest.getSizeBytes() / 1024) < MAX_MEMORY_KBYTES);
+ checkBlobSize(digest.getSizeBytes() / 1024, "Download");
byte[] data = cache.get(ContentDigests.toHexString(digest));
if (data == null) {
throw new CacheNotFoundException(digest);