@Override
public Iterator<ListItem> call() throws IOException {
if (nextMarker == null) {
return null;
}
ListItemBatch batch;
try {
batch = RetryHelper.runWithRetries(new Callable<ListItemBatch>() {
@Override
public ListItemBatch call() throws IOException {
long timeout = options.getRetryParams().getRequestTimeoutMillisForCurrentAttempt();
String marker = Strings.emptyToNull(nextMarker);
return raw.list(bucket, prefix, delimiter, marker, MAX_RESULTS_PER_BATCH, timeout);
}
}, options.getRetryParams(), exceptionHandler);
} catch (RetryInterruptedException ex) {
throw new ClosedByInterruptException();
} catch (NonRetriableException e) {
Throwables.propagateIfInstanceOf(e.getCause(), IOException.class);
throw e;
}
nextMarker = batch.getNextMarker();
return batch.getItems().iterator();
}
};
return new ListResult(batcher);
}