Skip to content

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

@janinko

Description

@janinko

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions