Issue with Java API Client - issue.getComments() always empty

I’m working on a java solution to do basic reporting against our Jira server instance and I’ve run into a problem. I can see that the REST API is returning the comments for an issue but the Java client library fails to parse the JSON and populate the list. After searching around a bit, I can see that others have run into the same problem but I’m not seeing any workarounds.

I’m using java-rest-client-core-4.0.0, which seems to pull in java-rest-client-api-4.0.0 and atlassian-httpclient-api-0.23.0 among other things.

com.atlassian.jira jira-rest-java-client-core 4.0.0

My code is something similar to the following:

try {

Promise<SearchResult> searchJqlPromise = jClient.getSearchClient().searchJql(jql,-1,0,null); 

Iterable<Issue> jIssues = searchJqlPromise.claim().getIssues();

	for (Issue issue : jIssues) {
	
		for(Comment comment : issue.getComments()) {
			//Do Stuff, but never get here because the list is always empty
		}

	}

} catch (Exception e) {

	e.printStackTrace();

}

This returns the values I need but the client library fails to load the comments and populate them into the model:

https://ourserverul:8443/rest/api/latest/issue/799066/comment

The other fields seem to be populating correctly. …Well, TimeTracking isn’t populating either but I’m able to pull those values from the custom fields collection.

Is there any known fix for this? I hate to start writing a custom client in parallel just to grab and parse the JSON from a separate rest call.

Thanks

Hi, @Matt3.

I faced the same problem and resolved it calling the IssueRestClient to reload the issue data. In your example, it could be:

	IssueRestClient issueClient = ...;

	for (Issue issue : jIssues) {
		Iterable<Comment> comments = issueClient.getIssue(issue.getKey()).claim().getComments();
		for(Comment comment : comments) {
			//Do Stuff
		}
	}
2 Likes