Unverified Commit ae1af6cf authored by Greg Messner's avatar Greg Messner Committed by GitHub
Browse files

Bug - Fixed issue with Pager when GitLab returns -1 for total-items. (#347)

* Fixed issue caused by the GitLab server returning -1 for total items (#346).
parent 59107379
...@@ -12,7 +12,7 @@ To utilize GitLab4J™ API in your Java project, simply add the following de ...@@ -12,7 +12,7 @@ To utilize GitLab4J™ API in your Java project, simply add the following de
```java ```java
dependencies { dependencies {
... ...
compile group: 'org.gitlab4j', name: 'gitlab4j-api', version: '4.10.12' compile group: 'org.gitlab4j', name: 'gitlab4j-api', version: '4.10.14'
} }
``` ```
...@@ -23,7 +23,7 @@ dependencies { ...@@ -23,7 +23,7 @@ dependencies {
<dependency> <dependency>
<groupId>org.gitlab4j</groupId> <groupId>org.gitlab4j</groupId>
<artifactId>gitlab4j-api</artifactId> <artifactId>gitlab4j-api</artifactId>
<version>4.10.12</version> <version>4.10.14</version>
</dependency> </dependency>
``` ```
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
<groupId>org.gitlab4j</groupId> <groupId>org.gitlab4j</groupId>
<artifactId>gitlab4j-api</artifactId> <artifactId>gitlab4j-api</artifactId>
<packaging>jar</packaging> <packaging>jar</packaging>
<version>4.10.13-SNAPSHOT</version> <version>4.10.14-SNAPSHOT</version>
<name>GitLab4J-API - GitLab API Java Client</name> <name>GitLab4J-API - GitLab API Java Client</name>
<description>GitLab4J-API (gitlab4j-api) provides a full featured Java client library for working with GitLab repositories and servers via the GitLab REST API.</description> <description>GitLab4J-API (gitlab4j-api) provides a full featured Java client library for working with GitLab repositories and servers via the GitLab REST API.</description>
<url>https://github.com/gitlab4j/gitlab4j-api</url> <url>https://github.com/gitlab4j/gitlab4j-api</url>
......
...@@ -343,17 +343,17 @@ public class Pager<T> implements Iterator<List<T>>, Constants { ...@@ -343,17 +343,17 @@ public class Pager<T> implements Iterator<List<T>>, Constants {
*/ */
public List<T> all() throws GitLabApiException { public List<T> all() throws GitLabApiException {
// Make sure that current page is 0, this will ensure the whole list is fetched // Make sure that current page is 0, this will ensure the whole list is fetched
// regardless of what page the instance is currently on. // regardless of what page the instance is currently on.
currentPage = 0; currentPage = 0;
List<T> allItems = new ArrayList<>(totalItems); List<T> allItems = new ArrayList<>(Math.max(totalItems, 0));
// Iterate through the pages and append each page of items to the list // Iterate through the pages and append each page of items to the list
while (hasNext()) { while (hasNext()) {
allItems.addAll(next()); allItems.addAll(next());
} }
return (allItems); return (allItems);
} }
/** /**
......
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