Skip to content

Commit

Permalink
fix endless loop for listHostedZones (#375)
Browse files Browse the repository at this point in the history
This result object has both `withMarker` and `withNextMarker`.
The marker is what was used for the request that generated the
result and should get ignored for pagination. Before, if the
call resulted in multiple pages, the marker would always have
a value for the last page and cause it to indicate that there
was another request. However it was correctly updating the
request with the result of next marker so it would start over
from the beginning.

The test case has been updated to reproduce the issue.
  • Loading branch information
brharrington authored Nov 30, 2018
1 parent df1eddc commit 7fb1056
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -205,9 +205,7 @@ private static <R, T> R getNextRequest(R request, T result) {
for (Method getter : result.getClass().getMethods()) {
if (getter.getName().equals(GET_NEXT[i])) {
Object next = getter.invoke(result);
if (!isNullOrEmpty(next)) {
hasNext = true;
}
hasNext = !isNullOrEmpty(next);
Method setter = request.getClass().getMethod(SET_NEXT[i], getter.getReturnType());
setter.invoke(request, next);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,11 @@ public void route53HostedZones() throws Exception {
if (r.getMarker() != null) {
Assert.assertEquals(reqIt.next(), r.getMarker());
}
// Hosted zones result has both withMarker and withNextMarker. Set withMarker to
// ensure it does not get used for pagination. Last issue is it manifested as an
// endless loop because the marker would get used if nextMarker was null.
return new ListHostedZonesResult()
.withMarker("test")
.withNextMarker(resIt.hasNext() ? resIt.next() : null);
};

Expand Down

0 comments on commit 7fb1056

Please sign in to comment.