Skip to content

getBranches() falls into an infinite loop #387

Description

@huhui

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions