You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jclouds.apache.org by za...@apache.org on 2015/08/06 16:45:04 UTC
jclouds git commit: Fix LocalBlobStore
Repository: jclouds
Updated Branches:
refs/heads/master eafdeb526 -> 53c3a4918
Fix LocalBlobStore
Project: http://git-wip-us.apache.org/repos/asf/jclouds/repo
Commit: http://git-wip-us.apache.org/repos/asf/jclouds/commit/53c3a491
Tree: http://git-wip-us.apache.org/repos/asf/jclouds/tree/53c3a491
Diff: http://git-wip-us.apache.org/repos/asf/jclouds/diff/53c3a491
Branch: refs/heads/master
Commit: 53c3a4918a2a20045694fa1b1bdc69ba717e6184
Parents: eafdeb5
Author: Roman Coedo <ro...@gmail.com>
Authored: Thu Aug 6 12:49:31 2015 +0200
Committer: Zack Shoylev <za...@rackspace.com>
Committed: Thu Aug 6 09:43:33 2015 -0500
----------------------------------------------------------------------
.../blobstore/config/LocalBlobStore.java | 26 +++++++++++---------
1 file changed, 14 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/jclouds/blob/53c3a491/blobstore/src/main/java/org/jclouds/blobstore/config/LocalBlobStore.java
----------------------------------------------------------------------
diff --git a/blobstore/src/main/java/org/jclouds/blobstore/config/LocalBlobStore.java b/blobstore/src/main/java/org/jclouds/blobstore/config/LocalBlobStore.java
index 5dba6e0..4a86087 100644
--- a/blobstore/src/main/java/org/jclouds/blobstore/config/LocalBlobStore.java
+++ b/blobstore/src/main/java/org/jclouds/blobstore/config/LocalBlobStore.java
@@ -661,6 +661,20 @@ public final class LocalBlobStore implements BlobStore {
if (options.getRanges() != null && !options.getRanges().isEmpty()) {
long size = 0;
ImmutableList.Builder<ByteSource> streams = ImmutableList.builder();
+
+ // We must call getRawContent to work around Blob.setPayload calling ByteSourcePayload.release. If the
+ // Local blobstore returns a ByteArrayPayload or FilePayload it uses a stream, otherwise it uses a
+ // byte array.
+ ByteSource byteSource;
+ try {
+ Object inputStream = blob.getPayload().getRawContent();
+ byteSource = (inputStream instanceof ByteArrayPayload || inputStream instanceof FilePayload) ?
+ (ByteSource) blob.getPayload().getRawContent()
+ : ByteSource.wrap(ByteStreams2.toByteArrayAndClose(blob.getPayload().openStream()));
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+
for (String s : options.getRanges()) {
// HTTP uses a closed interval while Java array indexing uses a
// half-open interval.
@@ -687,18 +701,6 @@ public final class LocalBlobStore implements BlobStore {
if (last + 1 > blob.getPayload().getContentMetadata().getContentLength()) {
last = blob.getPayload().getContentMetadata().getContentLength() - 1;
}
- // We must call getRawContent to work around Blob.setPayload calling ByteSourcePayload.release. If the
- // Local blobstore returns a ByteArrayPayload or FilePayload it uses a stream, otherwise it uses a
- // byte array.
- ByteSource byteSource;
- try {
- Object inputStream = blob.getPayload().getRawContent();
- byteSource = (inputStream instanceof ByteArrayPayload || inputStream instanceof FilePayload) ?
- (ByteSource) blob.getPayload().getRawContent()
- : ByteSource.wrap(ByteStreams2.toByteArrayAndClose(blob.getPayload().openStream()));
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
streams.add(byteSource.slice(offset, last - offset + 1));
size += last - offset + 1;
blob.getAllHeaders().put(HttpHeaders.CONTENT_RANGE,