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

Throwing an Error when an IOException occurs is overly fatal #65

Closed
ryankennedy opened this issue Jan 16, 2014 · 3 comments
Closed

Throwing an Error when an IOException occurs is overly fatal #65

ryankennedy opened this issue Jan 16, 2014 · 3 comments

Comments

@ryankennedy
Copy link
Contributor

https://github.com/kohsuke/github-api/blob/master/src/main/java/org/kohsuke/github/Requester.java#L268

When attempting to get the details of an empty repository, the github enterprise server returns an HTTP 409. This, in turn, causes Requester to throw an Error…

Caused by: java.io.IOException: Server returned HTTP response code: 409 for URL:

An Error, for those unfamiliar, is "a subclass of Throwable that indicates serious problems that a reasonable application should not try to catch." I don't think an HTTP 409 response warrants throwing an Error, thereby dooming the client Java process to exit with status code 1.

@kohsuke
Copy link
Collaborator

kohsuke commented Apr 13, 2014

This is because Iterator.next() cannot throw a checked exception. I don't see how to fix this.

@kohsuke kohsuke closed this as completed Apr 13, 2014
@aspyker
Copy link

aspyker commented Feb 10, 2016

Two questions ...

  1. Could we add something to repo for like isEmpty()? I see you can call getSize() and compare against 0, but I'm not sure if they would be absolutely guaranteed to be the same.
  2. In the case where you get an 409 with error status Git Repository Is Empty shouldn't the iterator hasNext just return false?

@aspyker
Copy link

aspyker commented Feb 12, 2016

Found this:

http://stackoverflow.com/questions/19889899/count-number-of-empty-repositories-on-github

I tried at first, repo.getSize == 0, but that had false positives. It seems like it rounds down in # of KB so projects with a few small files can still be 0.

So, now I'm experimenting with just not working with a repository if:

if (repo.getCreatedAt == repo.getPushedAt) {
// ignore repo
}

The fact that the github api doesn't help much to determine if a repo is empty and this issue makes it pretty hard to safely code a solution.

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

No branches or pull requests

3 participants