java-gitlab-api icon indicating copy to clipboard operation
java-gitlab-api copied to clipboard

getBranches() falls into an infinite loop

Open huhui opened this issue 4 years ago • 0 comments

When I am ready to use “getBranches”,my program falls into endless loop. My apiNamespace is "/api/v3".

GitlabAPI gitlabAPI  = GitlabAPI.connect(hostUrl,apiToken, TokenType.PRIVATE_TOKEN, AuthMethod.HEADER, "/api/v3");

Here are the “getBranches” details

public List<GitlabBranch> getBranches(Serializable projectId) {
        String tailUrl = GitlabProject.URL + "/" + sanitizeProjectId(projectId) + GitlabBranch.URL + PARAM_MAX_ITEMS_PER_PAGE;
        return retrieve().getAll(tailUrl, GitlabBranch[].class);
    }
   ||
  \||/
public <T> List<T> getAll(final String tailUrl, final Class<T[]> type) {
        List<T> results = new ArrayList<>();
        Iterator<T[]> iterator = asIterator(tailUrl, type);

        while (iterator.hasNext()) {
            T[] requests = iterator.next();

            if (requests.length > 0) {
                results.addAll(Arrays.asList(requests));
            }
        }
        return results;
    }

Can't jump out of the while loop

huhui avatar Feb 08 '21 12:02 huhui