github-api
github-api copied to clipboard
Issue with GHRepositoryStatistics.getContibutorStats(true)
https://github.com/hub4j/github-api/blob/4bba9680706785d6385ed69243f41a5f36757463/src/main/java/org/kohsuke/github/GHRepositoryStatistics.java#L67
This method will never invoke Thread.sleep if the data is not ready.
if (stats == null && waitTillReady) {
for (int i = 0; i < MAX_WAIT_ITERATIONS; i += 1) {
// Wait a few seconds and try again.
Thread.sleep(WAIT_SLEEP_INTERVAL);
stats = getContributorStatsImpl();
if (stats != null) {
break;
}
}
}
stats = getContributorStatsImpl() will never return null.
https://github.com/hub4j/github-api/blob/4bba9680706785d6385ed69243f41a5f36757463/src/main/java/org/kohsuke/github/Requester.java#L169
will always create a new instance of GitHubPageContentsIterable. Hence, if the data is still being cached by the server, the blocking will never happen and empty result will be returned back.
Expected behavior Based on GitHub API documentation: https://docs.github.com/en/rest/metrics/statistics#a-word-about-caching code 202 is returned back when the statistics data is not ready. Ideally status code of 202 returned by the REST call would be driving sleep and retry in GHRepositoryStatistics class. If the data is not ready, the method would block till the data is ready and return then.