Skip to content

Commit cf777fc

Browse files
committed
Fix setting ContentRange to inclusive positions
1 parent 6890fa1 commit cf777fc

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

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)