Skip to content

Commit 83ffe75

Browse files
committed
Fixed rate handling limit handling
Issue hub4j#220. If RateLimitHandler returns normally, it should retry.
1 parent 8cb7094 commit 83ffe75

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

src/main/java/org/kohsuke/github/Requester.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -501,6 +501,7 @@ private InputStream wrapStream(InputStream in) throws IOException {
501501

502502
if ("0".equals(uc.getHeaderField("X-RateLimit-Remaining"))) {
503503
root.rateLimitHandler.onError(e,uc);
504+
return;
504505
}
505506

506507
InputStream es = wrapStream(uc.getErrorStream());

src/test/java/Foo.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import org.kohsuke.github.GHRepository;
2+
import org.kohsuke.github.GHUser;
23
import org.kohsuke.github.GitHub;
34

45
import java.util.Collection;
@@ -14,4 +15,11 @@ public static void main(String[] args) throws Exception {
1415
}
1516
System.out.println(lst.size());
1617
}
18+
19+
private static void testRateLimit() throws Exception {
20+
GitHub g = GitHub.connectAnonymously();
21+
for (GHUser u : g.getOrganization("jenkinsci").listMembers()) {
22+
u.getFollowersCount();
23+
}
24+
}
1725
}

0 commit comments

Comments
 (0)