timols / java-gitlab-api

A wrapper for the Gitlab API written in Java
Apache License 2.0
387 stars 317 forks source link

getBranches() falls into an infinite loop #387

Open huhui opened 3 years ago

huhui commented 3 years ago

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