Jackson Infinite recursion

add-on
json
jira-server

#1

I’m trying to convert issue to Json, but i had “Stackoverflow” when using latest version jackson.databind or “Conflicting getter definitions for property” when using codehouse.jackson.xc.

On the old jira version it worked (6.2.7), updated to 7.11.2 and later it stopped working.

Now my code looks like this:

public String getIssuePresentation(Issue issue) throws IOException, URISyntaxException {
    ApplicationUser loggedInUser = jiraAuthenticationContext.getLoggedInUser();

    IssueBean issueBean = getIssueBean(issue);


    com.fasterxml.jackson.databind.ObjectMapper mapper = new com.fasterxml.jackson.databind.ObjectMapper();

    mapper.setVisibility(PropertyAccessor.FIELD, Visibility.ANY);
    mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
    mapper.setAnnotationIntrospector(new com.fasterxml.jackson.module.jaxb.JaxbAnnotationIntrospector(mapper.getTypeFactory()));
    mapper.setSerializationInclusion(Include.NON_NULL);

    return mapper1.writeValueAsString(issueBean);
}

private IssueBean getIssueBean(Issue issue) {
    BeanBuilderFactory beanBuilderFactory = ComponentAccessor
        .getOSGiComponentInstanceOfType(BeanBuilderFactory.class);
    JiraBaseUrls jiraBaseUrls = ComponentAccessor.getComponent(JiraBaseUrls.class);
    UriBuilder uriBuilder = UriBuilder.fromPath(jiraBaseUrls.restApi2BaseUrl());
    IssueBeanBuilder2 issueBeanBuilder = beanBuilderFactory
        .newIssueBeanBuilder2(IncludedFields.includeAllByDefault(null), "expand", uriBuilder);
    return issueBeanBuilder.build(issue);
  }

I tried using com.atlassian.adapter.jackson.ObjectMapper, and that works, but there is no “issueTypeLink" values in “issuelinks”.


#2

Don’t serialize the Issue object and send it over the wire. It will be very large. Can you not just use the Jira rest api for it?


#3

I can’t use rest api. Firstly, this is against logic, because this method is called on various events. Also, I add additional fields to the issueBean. The error falls when i create an issue, the special fields are then empty, so there can be no error due to them.