From bc78739ea92b6bbf322769eba336d6f0a6de95b5 Mon Sep 17 00:00:00 2001 From: Alin Dreghiciu Date: Wed, 7 Mar 2018 21:01:06 +0200 Subject: [PATCH] JCLOUDS-1392: Do not filter non BLOBs during list --- .../strategy/internal/FetchBlobMetadata.java | 25 ++++++++----------- .../BaseContainerIntegrationTest.java | 22 ++++++++++++++++ 2 files changed, 32 insertions(+), 15 deletions(-) diff --git a/blobstore/src/main/java/org/jclouds/blobstore/strategy/internal/FetchBlobMetadata.java b/blobstore/src/main/java/org/jclouds/blobstore/strategy/internal/FetchBlobMetadata.java index 79f10a4271..191ecbdb1e 100644 --- a/blobstore/src/main/java/org/jclouds/blobstore/strategy/internal/FetchBlobMetadata.java +++ b/blobstore/src/main/java/org/jclouds/blobstore/strategy/internal/FetchBlobMetadata.java @@ -24,9 +24,9 @@ import java.util.concurrent.Callable; import javax.annotation.Resource; import javax.inject.Named; +import com.google.common.util.concurrent.Futures; import org.jclouds.Constants; import org.jclouds.blobstore.BlobStore; -import org.jclouds.blobstore.domain.BlobMetadata; import org.jclouds.blobstore.domain.PageSet; import org.jclouds.blobstore.domain.StorageMetadata; import org.jclouds.blobstore.domain.StorageType; @@ -37,8 +37,6 @@ import org.jclouds.javax.annotation.concurrent.NotThreadSafe; import org.jclouds.logging.Logger; import com.google.common.base.Function; -import com.google.common.base.Predicate; -import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.ListeningExecutorService; @@ -81,19 +79,16 @@ public class FetchBlobMetadata implements Function apply(PageSet in) { checkState(container != null, "container name should be initialized"); - Iterable returnv = Lists.newArrayList(transformParallel(Iterables.filter(in, new Predicate() { + Iterable returnv = Lists.newArrayList(transformParallel(in, + new Function>() { @Override - public boolean apply(StorageMetadata input) { - return input.getType() == StorageType.BLOB; - } - - }), new Function>() { - - @Override - public ListenableFuture apply(final StorageMetadata from) { - return userExecutor.submit(new Callable() { - @Override public BlobMetadata call() throws Exception { + public ListenableFuture apply(final StorageMetadata from) { + if (from.getType() != StorageType.BLOB) { + return Futures.immediateFuture(from); + } + return userExecutor.submit(new Callable() { + @Override public StorageMetadata call() throws Exception { return blobstore.blobMetadata(container, from.getName()); } }); @@ -101,6 +96,6 @@ public class FetchBlobMetadata implements Function(returnv, in.getNextMarker()); + return new PageSetImpl(returnv, in.getNextMarker()); } } diff --git a/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseContainerIntegrationTest.java b/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseContainerIntegrationTest.java index 9c22fb8369..abbaba715d 100644 --- a/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseContainerIntegrationTest.java +++ b/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseContainerIntegrationTest.java @@ -552,6 +552,28 @@ public class BaseContainerIntegrationTest extends BaseBlobStoreIntegrationTest { } } + @Test(groups = {"integration", "live"}) + public void testContainerListWithDetails() throws InterruptedException { + final String containerName = getContainerName(); + BlobStore blobStore = view.getBlobStore(); + String prefix = "testContainerListWithDetails/"; + try { + blobStore.putBlob(containerName, blobStore.blobBuilder(prefix + "foo/bar").payload("").build()); + blobStore.putBlob(containerName, blobStore.blobBuilder(prefix + "car").payload("").build()); + checkEqualNames( + ImmutableSet.of(prefix + "foo/", prefix + "car"), + blobStore.list(containerName, ListContainerOptions.Builder.prefix(prefix).delimiter("/")) + ); + checkEqualNames( + ImmutableSet.of(prefix + "foo/", prefix + "car"), + blobStore.list(containerName, ListContainerOptions.Builder.prefix(prefix).delimiter("/").withDetails()) + ); + } + finally { + returnContainer(containerName); + } + } + @Test(groups = {"integration", "live"}) public void testDelimiterList() throws InterruptedException { final String containerName = getContainerName();