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();