You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jclouds.apache.org by ga...@apache.org on 2021/06/29 23:09:38 UTC
[jclouds] branch master updated: Re-optimize LocalBlobStore.getBlob
with ranges
This is an automated email from the ASF dual-hosted git repository.
gaul pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/jclouds.git
The following commit(s) were added to refs/heads/master by this push:
new d1bd51f Re-optimize LocalBlobStore.getBlob with ranges
d1bd51f is described below
commit d1bd51f7f1f1a5c8aad6cbbdffd9f30c1399fd2d
Author: Andrew Gaul <ga...@apache.org>
AuthorDate: Thu Jun 24 20:57:30 2021 +0900
Re-optimize LocalBlobStore.getBlob with ranges
This fixes a memory regression from
8de7b696e13f7131b3ea4a77b10f5cfd139dd712 where the transient BlobStore
changed from a ByteSource to a byte[].
---
.../java/org/jclouds/blobstore/config/LocalBlobStore.java | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
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 6921827..640c0d0 100644
--- a/blobstore/src/main/java/org/jclouds/blobstore/config/LocalBlobStore.java
+++ b/blobstore/src/main/java/org/jclouds/blobstore/config/LocalBlobStore.java
@@ -682,10 +682,13 @@ public final class LocalBlobStore implements BlobStore {
// Try to convert payload to ByteSource, otherwise wrap it.
ByteSource byteSource;
- try {
- byteSource = (ByteSource) blob.getPayload().getRawContent();
- } catch (ClassCastException cce) {
- // This should not happen; both FilesystemStorageStrategyImpl and TransientStorageStrategy return ByteSource
+ Object object = blob.getPayload().getRawContent();
+ if (object instanceof ByteSource) {
+ byteSource = (ByteSource) object;
+ } else if (object instanceof byte[]) {
+ byteSource = ByteSource.wrap((byte[]) object);
+ } else {
+ // This should not happen.
try {
byteSource = ByteSource.wrap(ByteStreams2.toByteArrayAndClose(blob.getPayload().openStream()));
} catch (IOException e) {