Skip to content

Commit 4cb8ae6

Browse files
committed
Try to avoid hitting secondary rate limit when opening issues
GitHub employs a secondary rate limit for actions that can trigger notifications, such as opening a new issue. To avoid hitting this limit, they recommend [1] waiting at least one second between each request. This commit attempts to comply with this guidance by adding a one-second sleep prior to each POST request that opens an issue. Closes gh-29879 [1] https://docs.github.com/en/rest/guides/best-practices-for-integrators#dealing-with-secondary-rate-limits
1 parent 21fb273 commit 4cb8ae6

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

buildSrc/src/main/java/org/springframework/boot/build/bom/bomr/github/StandardGitHubRepository.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2021 the original author or authors.
2+
* Copyright 2012-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -50,6 +50,12 @@ public int openIssue(String title, String body, List<String> labels, Milestone m
5050
requestBody.put("labels", labels);
5151
}
5252
requestBody.put("body", body);
53+
try {
54+
Thread.sleep(1000);
55+
}
56+
catch (InterruptedException ex) {
57+
Thread.currentThread().interrupt();
58+
}
5359
ResponseEntity<Map> response = this.rest.postForEntity("issues", requestBody, Map.class);
5460
return (Integer) response.getBody().get("number");
5561
}

0 commit comments

Comments
 (0)