Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix NullPointerException on RateLimitHandler when handling API errors. #179

Merged
merged 1 commit into from
Apr 20, 2015
Merged

Fix NullPointerException on RateLimitHandler when handling API errors. #179

merged 1 commit into from
Apr 20, 2015

Conversation

lskillen
Copy link
Contributor

Hello!

We encountered a NullPointerException after the upgrade to 1.67 when rate limited by the GitHub API. Essentially it is because the call to getMyself().getLogin() failed during the construction of the GitHub object due to being rate limited. However, the RateLimitHandler object had not yet been set at that point in time within the GitHub object constructor. Fix is a simple statement movement.

Error within GitHub::handleApiError():

        if ("0".equals(uc.getHeaderField("X-RateLimit-Remaining"))) {
            root.rateLimitHandler.onError(e,uc);  // rateLimitHandler is null
        }

Ran the test suite locally after setting github authentication details:

Results :

Failed tests:   setLabels(org.kohsuke.github.PullRequestTest): expected:<1> but was:<0>
  setAssignee(org.kohsuke.github.PullRequestTest): expected:<User:lskillen> but was:<null>

Tests in error:
  testMembership(org.kohsuke.github.AppTest): {"message":"Must have push access to view repository collaborators.","documentation_url":"https://developer.github.com/v3"}
  testListDeployments(org.kohsuke.github.AppTest): {"message":"No ref found for: master","documentation_url":"https://developer.github.com/v3"}
  testCreateDeployment(org.kohsuke.github.AppTest): {"message":"No ref found for: master","documentation_url":"https://developer.github.com/v3"}
  testMemberPagenation(org.kohsuke.github.AppTest): java.io.IOException: {"message":"Must have admin rights to Repository.","documentation_url":"https://developer.github.com/v3"}
  testRepoLabel(org.kohsuke.github.AppTest): {"message":"Not Found","documentation_url":"https://developer.github.com/v3/issues/labels/#create-a-label"}
  testGetDeploymentStatuses(org.kohsuke.github.AppTest): {"message":"No ref found for: master","documentation_url":"https://developer.github.com/v3"}
  testCreateRepository(org.kohsuke.github.LifecycleTest): java.io.IOException: {"message":"Must have admin rights to Repository.","documentation_url":"https://developer.github.com/v3"}

Tests run: 79, Failures: 2, Errors: 7, Skipped: 10

Failures seem to be mostly related to access to the github-api-test-org (which obviously I don't have any permissions for), and I had the same results before/after the change so it looks like they are unrelated to it - Hopefully that's acceptable!

Thanks,
Lee

@buildhive
Copy link

Kohsuke Kawaguchi » github-api #327 SUCCESS
This pull request looks good
(what's this?)

@KostyaSha
Copy link
Contributor

👍

1 similar comment
@oleg-nenashev
Copy link
Collaborator

👍

kohsuke added a commit that referenced this pull request Apr 20, 2015
Fix NullPointerException on RateLimitHandler when handling API errors.
@kohsuke kohsuke merged commit 1d2fbf2 into hub4j:master Apr 20, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants