diff --git a/src/main/java/org/kohsuke/github/GHTeam.java b/src/main/java/org/kohsuke/github/GHTeam.java index b8c6b1cb6f..acdc711cfb 100644 --- a/src/main/java/org/kohsuke/github/GHTeam.java +++ b/src/main/java/org/kohsuke/github/GHTeam.java @@ -2,10 +2,14 @@ import java.io.IOException; import java.util.Arrays; +import java.util.Collections; import java.util.HashSet; +import java.util.Iterator; +import java.util.LinkedHashSet; import java.util.Map; import java.util.Set; import java.util.TreeMap; +import java.util.TreeSet; /** * A team in GitHub organization. @@ -48,12 +52,27 @@ public int getId() { return id; } - /** - * Retrieves the current members. - */ - public Set getMembers() throws IOException { - return new HashSet(Arrays.asList(GHUser.wrap(org.root.retrieve().to(api("/members"), GHUser[].class), org.root))); - } + /** + * Retrieves the current members. + */ + public Set getMembers() throws IOException { + + Set members = new LinkedHashSet(); + + Iterator pageIterator = org.root.retrieve().asIterator(api("/members"), + GHUser[].class); + while (pageIterator != null && pageIterator.hasNext()) { + GHUser[] users = pageIterator.next(); + if (users != null) { + GHUser.wrap(users, org.root); + for (GHUser user : users) { + members.add(user); + } + } + } + + return Collections.unmodifiableSet(members); + } /** * Checks if this team has the specified user as a member.