Skip to content

Commit e1f0fab

Browse files
Adds extra check to prevent sleep(3000) call on last page of results
1 parent 314df6a commit e1f0fab

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/main/java/se/walkercrou/places/GooglePlaces.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,8 @@ private List<Place> getPlaces(String uri, String method, int limit) throws IOExc
394394
String raw = requestHandler.get(uri);
395395
debug(raw);
396396
String nextPage = parse(this, places, raw, limit);
397-
if (nextPage != null) {
397+
// reduce the limit, update the uri and wait for token, but only if there are more pages to read
398+
if (nextPage != null && i < pages - 1) {
398399
limit -= MAXIMUM_PAGE_RESULTS;
399400
uri = String.format("%s%s/json?pagetoken=%s&key=%s",
400401
API_URL, method, nextPage, apiKey);

0 commit comments

Comments
 (0)