Skip to content

AbuseLimitHandler does not handle scenarios where the local time is not synchronized with GitHub server time #1909

Closed

Description

@bitwiseman

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#L916

Unfortunately, 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:

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);
}

Activity

  1. changed the title [-]AbuseLimitHandler does handle scenarios where the local time is not synchronized with GitHub server time[/-] [+]AbuseLimitHandler does not handle scenarios where the local time is not synchronized with GitHub server time[/+] on Aug 19, 2024
  2. bitwiseman commented on Sep 27, 2024

    @bitwiseman
    MemberAuthor

    @holly-cummins
    Do you have to create a PR for this?

  3. holly-cummins commented on Sep 27, 2024

    @holly-cummins
    Contributor

    @holly-cummins Do you have time to create a PR for this?

    Sorry, yes! On my list but I keep getting sidetracked. Will bump it to the top.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions