Skip to content

Commit 9b54bf4

Browse files
committed
BUG Issue Comment id can be bigger than Integer.MAX
1 parent 8e90d6c commit 9b54bf4

File tree

4 files changed

+65
-8
lines changed

4 files changed

+65
-8
lines changed

src/main/java/com/spotify/github/v3/comment/Comment.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public interface Comment extends UpdateTracking {
4646
URI htmlUrl();
4747

4848
/** Comment ID. */
49-
int id();
49+
Long id();
5050

5151
/** The {@link User} that made the comment. */
5252
@Nullable

src/test/java/com/spotify/github/v3/clients/IssueClientTest.java

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ public void testCommentPaginationSpliterator() throws IOException {
8484
final List<Comment> listComments = Async.streamFromPaginatingIterable(pageIterator).collect(toList());
8585

8686
assertThat(listComments.size(), is(30));
87-
assertThat(listComments.get(0).id(), is(1345268));
88-
assertThat(listComments.get(listComments.size() - 1).id(), is(1356168));
87+
assertThat(listComments.get(0).id(), is(1345268L));
88+
assertThat(listComments.get(listComments.size() - 1).id(), is(1356168L));
8989
}
9090

9191
@Test
@@ -117,8 +117,8 @@ public void testCommentPaginationForeach() throws IOException {
117117
});
118118

119119
assertThat(listComments.size(), is(30));
120-
assertThat(listComments.get(0).id(), is(1345268));
121-
assertThat(listComments.get(listComments.size() - 1).id(), is(1356168));
120+
assertThat(listComments.get(0).id(), is(1345268L));
121+
assertThat(listComments.get(listComments.size() - 1).id(), is(1356168L));
122122
}
123123

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

133-
assertThat(comment.id(), is(114));
133+
assertThat(comment.id(), is(114L));
134+
}
135+
136+
@Test
137+
public void testCommentCreatedWithLargeId() throws IOException {
138+
final String fixture = loadFixture("clients/comment_created_long_id.json");
139+
final Response response = createMockResponse("", fixture);
140+
final String path = format(COMMENTS_URI_NUMBER_TEMPLATE, "someowner", "somerepo", 10);
141+
when(github.post(anyString(), anyString(), eq(Comment.class))).thenCallRealMethod();
142+
when(github.post(eq(path), anyString())).thenReturn(completedFuture(response));
143+
final Comment comment = issueClient.createComment(10, "Me too").join();
144+
145+
assertThat(comment.id(), is(2459198527L));
134146
}
135147
}

src/test/java/com/spotify/github/v3/clients/RepositoryClientTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,7 @@ public void testCommentCreated() throws IOException {
539539
.thenReturn(fixture);
540540
final Comment comment = repoClient.createComment("someweirdsha", "Me too").join();
541541

542-
assertThat(comment.id(), is(123));
542+
assertThat(comment.id(), is(123L));
543543
assertThat(comment.commitId().get(), is("6dcb09b5b57875f334f61aebed695e2e4193db5e"));
544544
}
545545

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

554-
assertThat(comment.id(), is(123));
554+
assertThat(comment.id(), is(123L));
555555
assertThat(comment.commitId().get(), is("6dcb09b5b57875f334f61aebed695e2e4193db5e"));
556556
}
557557

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
{
2+
"url": "https://api.github.com/repos/spotify/github-java-client/issues/comments/1958720937",
3+
"html_url": "https://github.com/spotify/github-java-client/pull/180#issuecomment-1958720937",
4+
"issue_url": "https://api.github.com/repos/spotify/github-java-client/issues/180",
5+
"id": 2459198527,
6+
"node_id": "IC_kwDODynaQc50v7Wp",
7+
"user": {
8+
"login": "vootelerotov",
9+
"id": 1439555,
10+
"node_id": "MDQ6VXNlcjE0Mzk1NTU=",
11+
"avatar_url": "https://avatars.githubusercontent.com/u/1439555?v=4",
12+
"gravatar_id": "",
13+
"url": "https://api.github.com/users/vootelerotov",
14+
"html_url": "https://github.com/vootelerotov",
15+
"followers_url": "https://api.github.com/users/vootelerotov/followers",
16+
"following_url": "https://api.github.com/users/vootelerotov/following{/other_user}",
17+
"gists_url": "https://api.github.com/users/vootelerotov/gists{/gist_id}",
18+
"starred_url": "https://api.github.com/users/vootelerotov/starred{/owner}{/repo}",
19+
"subscriptions_url": "https://api.github.com/users/vootelerotov/subscriptions",
20+
"organizations_url": "https://api.github.com/users/vootelerotov/orgs",
21+
"repos_url": "https://api.github.com/users/vootelerotov/repos",
22+
"events_url": "https://api.github.com/users/vootelerotov/events{/privacy}",
23+
"received_events_url": "https://api.github.com/users/vootelerotov/received_events",
24+
"type": "User",
25+
"user_view_type": "public",
26+
"site_admin": false
27+
},
28+
"created_at": "2024-02-22T05:19:44Z",
29+
"updated_at": "2024-02-22T05:19:44Z",
30+
"author_association": "CONTRIBUTOR",
31+
"body": "Ran into this in the wild.",
32+
"reactions": {
33+
"url": "https://api.github.com/repos/spotify/github-java-client/issues/comments/1958720937/reactions",
34+
"total_count": 0,
35+
"+1": 0,
36+
"-1": 0,
37+
"laugh": 0,
38+
"hooray": 0,
39+
"confused": 0,
40+
"heart": 0,
41+
"rocket": 0,
42+
"eyes": 0
43+
},
44+
"performed_via_github_app": null
45+
}

0 commit comments

Comments
 (0)