Merge pull request #636 from andrewgaul/filesystem-transient-tolerate-oversized-ranges

Tolerate oversized ranges in getBlob
This commit is contained in:
Adrian Cole 2012-05-14 15:24:36 -07:00
commit bab06133ff
2 changed files with 8 additions and 2 deletions

View File

@ -560,9 +560,12 @@ public class FilesystemAsyncBlobStore extends BaseAsyncBlobStore {
return immediateFailedFuture(new IllegalArgumentException("illegal range: " + s));
}
if (offset > last || last + 1 > data.length) {
if (offset > last) {
return immediateFailedFuture(new IllegalArgumentException("illegal range: " + s));
}
if (last + 1 > data.length) {
last = data.length - 1;
}
out.write(data, offset, last - offset + 1);
}
ContentMetadata cmd = blob.getPayload().getContentMetadata();

View File

@ -606,9 +606,12 @@ public class TransientAsyncBlobStore extends BaseAsyncBlobStore {
return immediateFailedFuture(new IllegalArgumentException("illegal range: " + s));
}
if (offset > last || last + 1 > data.length) {
if (offset > last) {
return immediateFailedFuture(new IllegalArgumentException("illegal range: " + s));
}
if (last + 1 > data.length) {
last = data.length - 1;
}
out.write(data, offset, last - offset + 1);
}
ContentMetadata cmd = blob.getPayload().getContentMetadata();