Skip to content

Commit a3028eb

Browse files
authored
Revert "[JENKINS-71849] Allow NoThrottle to be used even on github.com (#653)" (#730)
This reverts commit 51d5810.
1 parent 51d5810 commit a3028eb

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

src/main/java/org/jenkinsci/plugins/github_branch_source/ApiRateLimitChecker.java

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -100,13 +100,22 @@ long checkRateLimitImpl(@NonNull GHRateLimit.Record rateLimit, long count, long
100100
NoThrottle(Messages.ApiRateLimitChecker_NoThrottle()) {
101101
@Override
102102
public LocalChecker getChecker(@NonNull TaskListener listener, String apiUrl) {
103-
return new LocalChecker(listener) {
104-
@Override
105-
long checkRateLimitImpl(@NonNull GHRateLimit.Record rateLimit, long count, long now)
106-
throws InterruptedException {
107-
return now;
108-
}
109-
};
103+
if (GitHubServerConfig.GITHUB_URL.equals(apiUrl)) {
104+
// If the GitHub public API is being used, this will fallback to ThrottleOnOver
105+
LocalChecker checker = ThrottleOnOver.getChecker(listener, apiUrl);
106+
checker.writeLog(
107+
"GitHub throttling is disabled, which is not allowed for public GitHub usage, "
108+
+ "so ThrottleOnOver will be used instead. To configure a different rate limiting strategy, go to \"GitHub API usage\" under \"Configure System\" in the Jenkins settings.");
109+
return checker;
110+
} else {
111+
return new LocalChecker(listener) {
112+
@Override
113+
long checkRateLimitImpl(@NonNull GHRateLimit.Record rateLimit, long count, long now)
114+
throws InterruptedException {
115+
return now;
116+
}
117+
};
118+
}
110119
}
111120
};
112121

src/test/java/org/jenkinsci/plugins/github_branch_source/ApiRateLimitCheckerTest.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
import org.jenkinsci.plugins.github.config.GitHubServerConfig;
2828
import org.junit.After;
2929
import org.junit.Before;
30-
import org.junit.Ignore;
3130
import org.junit.Test;
3231
import org.kohsuke.github.GHRateLimit;
3332
import org.kohsuke.github.GitHub;
@@ -160,7 +159,6 @@ private void setupStubs(List<RateLimit> scenarios) throws Exception {
160159
assertEquals(2, initialRequestCount);
161160
}
162161

163-
@Ignore("behavior deliberately modified")
164162
@Test
165163
public void NoCheckerConfigured() throws Exception {
166164
// set up scenarios
@@ -351,7 +349,6 @@ public void NoThrottleTestShouldNotThrottle404() throws Exception {
351349
*
352350
* @author Marc Salles Navarro
353351
*/
354-
@Ignore("behavior deliberately modified")
355352
@Test
356353
public void NoThrottleTestShouldFallbackToThrottleOnOverForGitHubDotCom() throws Exception {
357354
GitHubConfiguration.get().setApiRateLimitChecker(ApiRateLimitChecker.ThrottleOnOver);

0 commit comments

Comments
 (0)