fix range get for manifest object

swift doesn't return the etag if the client is doing a range
get of a manifest (SLO or DLO), this fixes SwiftObject so
etag is optional
This commit is contained in:
Ka-Hing Cheung 2015-06-09 17:23:21 -07:00
parent 25ec655d74
commit 6ed95d8968
2 changed files with 27 additions and 1 deletions

View File

@ -53,7 +53,7 @@ public class SwiftObject implements Comparable<SwiftObject> {
Multimap<String, String> headers, Map<String, String> metadata, Payload payload) {
this.name = checkNotNull(name, "name");
this.uri = checkNotNull(uri, "uri of %s", uri);
this.etag = checkNotNull(etag, "etag of %s", name).replace("\"", "");
this.etag = etag != null ? etag.replace("\"", "") : null;
this.lastModified = checkNotNull(lastModified, "lastModified of %s", name);
this.headers = headers == null ? ImmutableMultimap.<String, String> of() : checkNotNull(headers, "headers of %s", name);
this.metadata = metadata == null ? ImmutableMap.<String, String> of() : metadata;

View File

@ -426,6 +426,32 @@ public class BaseBlobIntegrationTest extends BaseBlobStoreIntegrationTest {
}
}
@Test(groups = { "integration", "live" })
public void testGetRangeMultipart() throws InterruptedException, IOException {
String container = getContainerName();
InputStream expect = null;
InputStream actual = null;
try {
String name = "apples";
long length = getMinimumMultipartBlobSize();
ByteSource byteSource = TestUtils.randomByteSource().slice(0, length);
Blob blob = view.getBlobStore().blobBuilder(name)
.payload(byteSource)
.contentLength(length)
.build();
view.getBlobStore().putBlob(container, blob, new PutOptions().multipart(true));
blob = view.getBlobStore().getBlob(container, name, range(0, 5));
validateMetadata(blob.getMetadata(), container, name);
expect = byteSource.slice(0, 6).openStream();
actual = blob.getPayload().openStream();
assertThat(actual).hasContentEqualTo(expect);
} finally {
Closeables2.closeQuietly(expect);
Closeables2.closeQuietly(actual);
returnContainer(container);
}
}
private String addObjectAndValidateContent(String sourcecontainer, String sourceKey) throws InterruptedException {
String eTag = addBlobToContainer(sourcecontainer, sourceKey);
validateContent(sourcecontainer, sourceKey);