Skip to content

Commit

Permalink
Fixed rate handling limit handling
Browse files Browse the repository at this point in the history
Issue #220. If RateLimitHandler returns normally, it should retry.
  • Loading branch information
kohsuke committed Dec 2, 2015
1 parent 8cb7094 commit 83ffe75
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/main/java/org/kohsuke/github/Requester.java
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,7 @@ private InputStream wrapStream(InputStream in) throws IOException {

if ("0".equals(uc.getHeaderField("X-RateLimit-Remaining"))) {
root.rateLimitHandler.onError(e,uc);
return;
}

InputStream es = wrapStream(uc.getErrorStream());
Expand Down
8 changes: 8 additions & 0 deletions src/test/java/Foo.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import org.kohsuke.github.GHRepository;
import org.kohsuke.github.GHUser;
import org.kohsuke.github.GitHub;

import java.util.Collection;
Expand All @@ -14,4 +15,11 @@ public static void main(String[] args) throws Exception {
}
System.out.println(lst.size());
}

private static void testRateLimit() throws Exception {
GitHub g = GitHub.connectAnonymously();
for (GHUser u : g.getOrganization("jenkinsci").listMembers()) {
u.getFollowersCount();
}
}
}

0 comments on commit 83ffe75

Please sign in to comment.