Commit ea9daebb authored by Greg Messner's avatar Greg Messner
Browse files

Added handling of results from GitLab API that are missing headers (#286).

parent 86732490
...@@ -93,9 +93,22 @@ public class Pager<T> implements Iterator<List<T>>, Constants { ...@@ -93,9 +93,22 @@ public class Pager<T> implements Iterator<List<T>>, Constants {
this.api = api; this.api = api;
this.queryParams = queryParams; this.queryParams = queryParams;
this.pathArgs = pathArgs; this.pathArgs = pathArgs;
this.itemsPerPage = getHeaderValue(response, PER_PAGE);
totalPages = getHeaderValue(response, TOTAL_PAGES_HEADER); try {
totalItems = getHeaderValue(response, TOTAL_HEADER); this.itemsPerPage = getHeaderValue(response, PER_PAGE);
totalPages = getHeaderValue(response, TOTAL_PAGES_HEADER);
totalItems = getHeaderValue(response, TOTAL_HEADER);
} catch (GitLabApiException glae) {
// Some API endpoints do not return the proper headers, check for that condition and act accordingly
if (currentItems != null && currentItems.size() < itemsPerPage) {
this.itemsPerPage = itemsPerPage;
totalPages = 1;
totalItems = currentItems.size();
} else {
throw (glae);
}
}
} }
/** /**
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment