Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
佳 邓
Gitlab4j Api
Commits
ea9daebb
Commit
ea9daebb
authored
Dec 29, 2018
by
Greg Messner
Browse files
Added handling of results from GitLab API that are missing headers (#286).
parent
86732490
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/main/java/org/gitlab4j/api/Pager.java
View file @
ea9daebb
...
...
@@ -93,9 +93,22 @@ public class Pager<T> implements Iterator<List<T>>, Constants {
this
.
api
=
api
;
this
.
queryParams
=
queryParams
;
this
.
pathArgs
=
pathArgs
;
this
.
itemsPerPage
=
getHeaderValue
(
response
,
PER_PAGE
);
totalPages
=
getHeaderValue
(
response
,
TOTAL_PAGES_HEADER
);
totalItems
=
getHeaderValue
(
response
,
TOTAL_HEADER
);
try
{
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
);
}
}
}
/**
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment