Skip to content

Commit

Permalink
Re-optimize LocalBlobStore.getBlob with ranges
Browse files Browse the repository at this point in the history
This fixes a memory regression from
8de7b69 where the transient BlobStore
changed from a ByteSource to a byte[].
  • Loading branch information
gaul committed Jun 29, 2021
1 parent 2791f47 commit d1bd51f
Showing 1 changed file with 7 additions and 4 deletions.
Expand Up @@ -682,10 +682,13 @@ public Blob getBlob(String containerName, String key, GetOptions options) {

// 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) {
Expand Down

0 comments on commit d1bd51f

Please sign in to comment.