Skip to content

Commit

Permalink
BUG Issue Comment id can be bigger than Integer.MAX
Browse files Browse the repository at this point in the history
  • Loading branch information
sindunuragarp committed Nov 25, 2024
1 parent 8e90d6c commit 9b54bf4
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/main/java/com/spotify/github/v3/comment/Comment.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public interface Comment extends UpdateTracking {
URI htmlUrl();

/** Comment ID. */
int id();
Long id();

/** The {@link User} that made the comment. */
@Nullable
Expand Down
22 changes: 17 additions & 5 deletions src/test/java/com/spotify/github/v3/clients/IssueClientTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ public void testCommentPaginationSpliterator() throws IOException {
final List<Comment> listComments = Async.streamFromPaginatingIterable(pageIterator).collect(toList());

assertThat(listComments.size(), is(30));
assertThat(listComments.get(0).id(), is(1345268));
assertThat(listComments.get(listComments.size() - 1).id(), is(1356168));
assertThat(listComments.get(0).id(), is(1345268L));
assertThat(listComments.get(listComments.size() - 1).id(), is(1356168L));
}

@Test
Expand Down Expand Up @@ -117,8 +117,8 @@ public void testCommentPaginationForeach() throws IOException {
});

assertThat(listComments.size(), is(30));
assertThat(listComments.get(0).id(), is(1345268));
assertThat(listComments.get(listComments.size() - 1).id(), is(1356168));
assertThat(listComments.get(0).id(), is(1345268L));
assertThat(listComments.get(listComments.size() - 1).id(), is(1356168L));
}

@Test
Expand All @@ -130,6 +130,18 @@ public void testCommentCreated() throws IOException {
when(github.post(eq(path), anyString())).thenReturn(completedFuture(response));
final Comment comment = issueClient.createComment(10, "Me too").join();

assertThat(comment.id(), is(114));
assertThat(comment.id(), is(114L));
}

@Test
public void testCommentCreatedWithLargeId() throws IOException {
final String fixture = loadFixture("clients/comment_created_long_id.json");
final Response response = createMockResponse("", fixture);
final String path = format(COMMENTS_URI_NUMBER_TEMPLATE, "someowner", "somerepo", 10);
when(github.post(anyString(), anyString(), eq(Comment.class))).thenCallRealMethod();
when(github.post(eq(path), anyString())).thenReturn(completedFuture(response));
final Comment comment = issueClient.createComment(10, "Me too").join();

assertThat(comment.id(), is(2459198527L));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ public void testCommentCreated() throws IOException {
.thenReturn(fixture);
final Comment comment = repoClient.createComment("someweirdsha", "Me too").join();

assertThat(comment.id(), is(123));
assertThat(comment.id(), is(123L));
assertThat(comment.commitId().get(), is("6dcb09b5b57875f334f61aebed695e2e4193db5e"));
}

Expand All @@ -551,7 +551,7 @@ public void getComment() throws IOException {
.thenReturn(fixture);
final Comment comment = repoClient.getComment(123).join();

assertThat(comment.id(), is(123));
assertThat(comment.id(), is(123L));
assertThat(comment.commitId().get(), is("6dcb09b5b57875f334f61aebed695e2e4193db5e"));
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"url": "https://api.github.com/repos/spotify/github-java-client/issues/comments/1958720937",
"html_url": "https://github.com/spotify/github-java-client/pull/180#issuecomment-1958720937",
"issue_url": "https://api.github.com/repos/spotify/github-java-client/issues/180",
"id": 2459198527,
"node_id": "IC_kwDODynaQc50v7Wp",
"user": {
"login": "vootelerotov",
"id": 1439555,
"node_id": "MDQ6VXNlcjE0Mzk1NTU=",
"avatar_url": "https://avatars.githubusercontent.com/u/1439555?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/vootelerotov",
"html_url": "https://github.com/vootelerotov",
"followers_url": "https://api.github.com/users/vootelerotov/followers",
"following_url": "https://api.github.com/users/vootelerotov/following{/other_user}",
"gists_url": "https://api.github.com/users/vootelerotov/gists{/gist_id}",
"starred_url": "https://api.github.com/users/vootelerotov/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/vootelerotov/subscriptions",
"organizations_url": "https://api.github.com/users/vootelerotov/orgs",
"repos_url": "https://api.github.com/users/vootelerotov/repos",
"events_url": "https://api.github.com/users/vootelerotov/events{/privacy}",
"received_events_url": "https://api.github.com/users/vootelerotov/received_events",
"type": "User",
"user_view_type": "public",
"site_admin": false
},
"created_at": "2024-02-22T05:19:44Z",
"updated_at": "2024-02-22T05:19:44Z",
"author_association": "CONTRIBUTOR",
"body": "Ran into this in the wild.",
"reactions": {
"url": "https://api.github.com/repos/spotify/github-java-client/issues/comments/1958720937/reactions",
"total_count": 0,
"+1": 0,
"-1": 0,
"laugh": 0,
"hooray": 0,
"confused": 0,
"heart": 0,
"rocket": 0,
"eyes": 0
},
"performed_via_github_app": null
}

0 comments on commit 9b54bf4

Please sign in to comment.