Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deep copy Blob in LocalBlobStore.getBlob #150

Merged
merged 1 commit into from
Aug 4, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,22 @@ public Iterable<String> getBlobKeysInsideContainer(final String containerName, S
@Override
public Blob getBlob(final String containerName, final String blobName) {
Map<String, Blob> map = containerToBlobs.get(containerName);
return map == null ? null : map.get(blobName);
if (map == null) {
return null;
}
Blob blob = map.get(blobName);
if (blob == null) {
return null;
}

// Deep copy Blob to make sure ByteSourcePayload does not share Closer.
Payload payload = blob.getPayload();
MutableContentMetadata md = payload.getContentMetadata();
Blob newBlob = blobFactory.create(BlobStoreUtils.copy(blob.getMetadata()));
Payload newPayload = Payloads.newPayload(payload.getRawContent());
newBlob.setPayload(payload);
HttpUtils.copy(md, newPayload.getContentMetadata());
return newBlob;
}

@Override
Expand Down