Use parseLong instead of parseInt in range parser

Use parseLong instead of parseInt when parsing open-ended byte ranges in LocalBlobStore. Without this fix, any "from byte x" or "to byte x" getBlob() call will throw a NumberFormatException if x is too big to fit into an int (2 GB).

Fixes https://issues.apache.org/jira/browse/JCLOUDS-1073
This commit is contained in:
quod3 2016-01-30 20:11:07 -05:00
parent 6360023f09
commit 77eef902b4
1 changed files with 2 additions and 2 deletions

View File

@ -662,12 +662,12 @@ public final class LocalBlobStore implements BlobStore {
long offset = 0;
long last = blob.getPayload().getContentMetadata().getContentLength() - 1;
if (s.startsWith("-")) {
offset = last - Integer.parseInt(s.substring(1)) + 1;
offset = last - Long.parseLong(s.substring(1)) + 1;
if (offset < 0) {
offset = 0;
}
} else if (s.endsWith("-")) {
offset = Integer.parseInt(s.substring(0, s.length() - 1));
offset = Long.parseLong(s.substring(0, s.length() - 1));
} else if (s.contains("-")) {
String[] firstLast = s.split("\\-");
offset = Long.parseLong(firstLast[0]);