> +         marker = set.getNextMarker();
> +         iterator = set.iterator();
> +      }
> +
> +      @Override
> +      public boolean hasNext() {
> +         return iterator.hasNext() || marker != null;
> +      }
> +
> +      @Override
> +      public StorageMetadata next() {
> +         while (true) {
> +            if (!iterator.hasNext()) {
> +               advance();
> +            }
> +            StorageMetadata metadata = iterator.next();

Changes lgtm now. However, advancing the iterator in the `hasNext` is not the 
best pattern to use. I'd suggest to use the Guava's `AbstractIterator` to 
implement the iterator. You can take a look at the GCE's 
[AdvancingIterator](https://github.com/jclouds/jclouds-labs-google/blob/master/googlecloud/src/main/java/org/jclouds/googlecloud/internal/AdvancingIterator.java),
 which does pretty much the same. Your `crawl` methods should use that iterator 
and the [this concat 
method](https://github.com/jclouds/jclouds-labs-google/blob/master/googlecloud/src/main/java/org/jclouds/googlecloud/internal/ListPages.java#L34-44)
 to return an Iterator that can advance between pages, without having to change 
the state of the iterator in the `hasNext` method. WDYT?

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/702/files#r26255537

Reply via email to