Change AWSEC2ImageSupplier to return a ForwardingSet, instead of an ImmutableSet. This means the set returned by the Image supplier will reflect changes in the underlying cache.

This commit is contained in:
Richard Downer 2012-01-09 10:27:30 +02:00
parent 5c2e2576bf
commit 0ab8ea1bee
1 changed files with 6 additions and 1 deletions

View File

@ -34,6 +34,7 @@ import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;
import com.google.common.collect.ForwardingSet;
import org.jclouds.Constants;
import org.jclouds.aws.ec2.compute.config.ClusterCompute;
import org.jclouds.compute.domain.Image;
@ -127,7 +128,11 @@ public class AWSEC2ImageSupplier implements Supplier<Set<? extends Image>> {
logger.debug("<< images(%d)", imageMap.size());
// TODO Used to be mutable; was this assumed anywhere?
return ImmutableSet.copyOf(imageMap.values());
return new ForwardingSet<Image>() {
protected Set<Image> delegate() {
return ImmutableSet.copyOf(cache.get().asMap().values());
}
};
}
private Future<Iterable<Image>> images(Iterable<String> regions, String query, String tag) {