remote: close file when uploading

RELNOTES: None
PiperOrigin-RevId: 166841380
diff --git a/src/main/java/com/google/devtools/build/lib/remote/SimpleBlobStoreActionCache.java b/src/main/java/com/google/devtools/build/lib/remote/SimpleBlobStoreActionCache.java
index 645a693..641cf64 100644
--- a/src/main/java/com/google/devtools/build/lib/remote/SimpleBlobStoreActionCache.java
+++ b/src/main/java/com/google/devtools/build/lib/remote/SimpleBlobStoreActionCache.java
@@ -92,8 +92,10 @@
   }
 
   private Digest uploadFileContents(Path file) throws IOException, InterruptedException {
-    // This unconditionally reads the whole file into memory first!
-    return uploadBlob(ByteString.readFrom(file.getInputStream()).toByteArray());
+    try (InputStream in = file.getInputStream()) {
+      // This unconditionally reads the whole file into memory first!
+      return uploadBlob(ByteString.readFrom(in).toByteArray());
+    }
   }
 
   private Digest uploadFileContents(