Skip to content

Commit d039537

Browse files
committed
Merge pull request #375 from mziccard/fix-content-range
Fix setting ContentRange to inclusive positions
2 parents b7099e0 + cf777fc commit d039537

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

gcloud-java-storage/src/main/java/com/google/gcloud/spi/DefaultStorageRpc.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
import com.google.common.base.MoreObjects;
6161
import com.google.common.collect.ImmutableSet;
6262
import com.google.common.collect.Maps;
63+
import com.google.common.primitives.Ints;
6364
import com.google.gcloud.storage.StorageException;
6465
import com.google.gcloud.storage.StorageOptions;
6566

@@ -415,7 +416,7 @@ public byte[] read(StorageObject from, Map<Option, ?> options, long position, in
415416
.setIfGenerationMatch(IF_GENERATION_MATCH.getLong(options))
416417
.setIfGenerationNotMatch(IF_GENERATION_NOT_MATCH.getLong(options));
417418
MediaHttpDownloader downloader = req.getMediaHttpDownloader();
418-
downloader.setContentRange(position, (int) position + bytes);
419+
downloader.setContentRange(position, Ints.checkedCast(position + bytes - 1));
419420
downloader.setDirectDownloadEnabled(true);
420421
ByteArrayOutputStream output = new ByteArrayOutputStream();
421422
req.executeMediaAndDownloadTo(output);

0 commit comments

Comments
 (0)