-
Notifications
You must be signed in to change notification settings - Fork 769
Description
From this comment on #1895 :
GitHubClient has a method to get Date (or Instant).
https://github.com/hub4j/github-api/blob/main/src/main/java/org/kohsuke/github/GitHubClient.java#L916Unfortunately, diff from local machine time is not reliable. The local machine may not be synchronized with the server time. We have to use the diff from the response time.
https://github.com/hub4j/github-api/blob/main/src/main/java/org/kohsuke/github/GHRateLimit.java#L543-L571
However, this PR is a huge step forward and I'd rather have this less than perfect code added than wait for the next release.
This is the code that need updating:
github-api/src/main/java/org/kohsuke/github/AbuseLimitHandler.java
Lines 116 to 122 in 314917e
| try { | |
| return Math.max(1000, Long.parseLong(v) * 1000); | |
| } catch (NumberFormatException nfe) { | |
| // The retry-after header could be a number in seconds, or an http-date | |
| ZonedDateTime zdt = ZonedDateTime.parse(v, DateTimeFormatter.RFC_1123_DATE_TIME); | |
| return ChronoUnit.MILLIS.between(ZonedDateTime.now(), zdt); | |
| } |