From f55231d60779fb134463a736d9e5d8b8a253a4ab Mon Sep 17 00:00:00 2001 From: Andrew Gaul Date: Mon, 14 May 2012 15:15:54 -0700 Subject: [PATCH] Tolerate oversized ranges in getBlob --- .../org/jclouds/filesystem/FilesystemAsyncBlobStore.java | 5 ++++- .../java/org/jclouds/blobstore/TransientAsyncBlobStore.java | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/apis/filesystem/src/main/java/org/jclouds/filesystem/FilesystemAsyncBlobStore.java b/apis/filesystem/src/main/java/org/jclouds/filesystem/FilesystemAsyncBlobStore.java index d570e8be1d..33bf078aad 100644 --- a/apis/filesystem/src/main/java/org/jclouds/filesystem/FilesystemAsyncBlobStore.java +++ b/apis/filesystem/src/main/java/org/jclouds/filesystem/FilesystemAsyncBlobStore.java @@ -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(); diff --git a/blobstore/src/main/java/org/jclouds/blobstore/TransientAsyncBlobStore.java b/blobstore/src/main/java/org/jclouds/blobstore/TransientAsyncBlobStore.java index 182d015093..ed85a5ca0f 100644 --- a/blobstore/src/main/java/org/jclouds/blobstore/TransientAsyncBlobStore.java +++ b/blobstore/src/main/java/org/jclouds/blobstore/TransientAsyncBlobStore.java @@ -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();