Skip to content

Commit

Permalink
Let's not break everyone with paged list yet
Browse files Browse the repository at this point in the history
  • Loading branch information
jianghaolu committed Sep 15, 2016
1 parent 0eb2adc commit 29bcf65
Showing 1 changed file with 16 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@

package com.microsoft.azure;

import com.microsoft.rest.RestException;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
Expand Down Expand Up @@ -51,13 +54,17 @@ public PagedList(Page<E> page) {
}

private void cachePage(String nextPageLink) {
while (nextPageLink != null) {
cachedPage = nextPage(nextPageLink);
nextPageLink = cachedPage.getNextPageLink();
if (hasNextPage()) {
// a legit, non-empty page has been fetched, otherwise keep fetching
break;
try {
while (nextPageLink != null) {
cachedPage = nextPage(nextPageLink);
nextPageLink = cachedPage.getNextPageLink();
if (hasNextPage()) {
// a legit, non-empty page has been fetched, otherwise keep fetching
break;
}
}
} catch (IOException ex) {
throw new RuntimeException(ex);
}
}

Expand All @@ -66,8 +73,10 @@ private void cachePage(String nextPageLink) {
*
* @param nextPageLink the link to get the next page of items.
* @return the {@link Page} object storing a page of items and a link to the next page.
* @throws RestException thrown if an error is raised from Azure.
* @throws IOException thrown if there's any failure in deserialization.
*/
public abstract Page<E> nextPage(String nextPageLink);
public abstract Page<E> nextPage(String nextPageLink) throws RestException, IOException;

/**
* If there are more pages available.
Expand Down

0 comments on commit 29bcf65

Please sign in to comment.