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

GHIssue.getComments() throws NoSuchElementException when there are no comments #20

Closed
janinko opened this issue Sep 10, 2012 · 2 comments

Comments

@janinko
Copy link
Collaborator

janinko commented Sep 10, 2012

When trying to get comments for pull requests with no comments NoSuchElementException is thrown.
I would except empty list instead.

java.util.NoSuchElementException
    at org.kohsuke.github.Requester$1.next(Requester.java:212)
    at org.kohsuke.github.PagedIterator.fetch(PagedIterator.java:42)
    at org.kohsuke.github.PagedIterator.nextPage(PagedIterator.java:57)
    at org.kohsuke.github.PagedIterable.asList(PagedIterable.java:20)
    at org.kohsuke.github.GHIssue.getComments(GHIssue.java:184)

API response for /repos/janinko/test/issues/7/comments with no comments - there are no Link header and returns empty array:

HTTP/1.1 200 OK
Server: nginx
Date: Mon, 10 Sep 2012 12:11:37 GMT
Content-Type: application/json; charset=utf-8
Connection: keep-alive
Status: 200 OK
Cache-Control: max-age=0, private, must-revalidate
X-Content-Type-Options: nosniff
ETag: "a00049ba79152d03380c34652f2cb612"
Content-Length: 5
X-RateLimit-Limit: 5000
X-GitHub-Media-Type: github.beta
X-RateLimit-Remaining: 4957

[

]

So IMHO in PagedIterable.asList() i.hasNext() returns true because it has next (but empty) array.

@branan
Copy link

branan commented Sep 10, 2012

I'm seeing this issue out in the real world. It's blocking me from being able to deploy the (otherwise excellent) Jenkins pull request builder in my environment.

kohsuke added a commit that referenced this issue Sep 13, 2012
PagedIterator is updated to cope with the base iterator returning array of length 0
@kohsuke
Copy link
Collaborator

kohsuke commented Sep 13, 2012

Fixed in upcoming 1.33.

@kohsuke kohsuke closed this as completed Sep 13, 2012
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