AttlasianWikiRenderer 7.6 is not compatible with older versions

Am using the following code in the jira plugin for jira <7.5.3:

 public static String convertJiraDescriptionToHtml(String jiraDescription) {
        EventPublisher eventPublisher = ComponentAccessor.getOSGiComponentInstanceOfType (EventPublisher.class);
        VelocityRequestContextFactory velocityRequestContextFactory = ComponentAccessor.getOSGiComponentInstanceOfType(VelocityRequestContextFactory.class);
        ApplicationProperties app = ComponentAccessor.getApplicationProperties();
        AtlassianWikiRenderer wikiRenderer = new AtlassianWikiRenderer(eventPublisher, app, velocityRequestContextFactory, featureManager);
        return wikiRenderer.render(JiraDescriptionConverter.replaceJiraSpecialCharacters(jiraDescription), null);
    }

The AttlasianWikiRenderer has been changed in the 7.6.0 Wiki
So the code should be now like this:

public static String convertJiraDescriptionToHtml(String jiraDescription) {
        EventPublisher eventPublisher = ComponentAccessor.getOSGiComponentInstanceOfType (EventPublisher.class);
        VelocityRequestContextFactory velocityRequestContextFactory = ComponentAccessor.getOSGiComponentInstanceOfType(VelocityRequestContextFactory.class);
        FeatureManager featureManager = ComponentAccessor.getComponent(FeatureManager.class);
        ApplicationProperties app = ComponentAccessor.getApplicationProperties();
        AtlassianWikiRenderer wikiRenderer = new AtlassianWikiRenderer(eventPublisher, app, velocityRequestContextFactory, featureManager);
        return wikiRenderer.render(JiraDescriptionConverter.replaceJiraSpecialCharacters(jiraDescription), null);
    }

Consider that we need to add new FeatureManager param.

The problem is, that when we compile plugin for jira 7.6 and install plugin on <7.6, the new implementaion throws NoSuchMethodError.

How to provide compatibility for both <7.6 and 7.6.X version?

1 Like

Jira Support replied to me to use DefaultRenderManager to get AltassianWikiRender. Then initialization is then moved to the platform.
Works both for <7.6 and 7.6.X

//imports
import com.atlassian.jira.issue.fields.renderer.JiraRendererPlugin;
import com.atlassian.jira.issue.fields.renderer.wiki.AtlassianWikiRenderer;
import com.atlassian.jira.issue.managers.DefaultRendererManager;

//convert solution
public static String convertJiraDescriptionToHtml(String jiraDescription) {
        JiraRendererPlugin wikiRender = new DefaultRendererManager(ComponentAccessor.getPluginAccessor()).getRendererForType(AtlassianWikiRenderer.RENDERER_TYPE);
        return wikiRender.render(JiraDescriptionConverter.replaceJiraSpecialCharacters(jiraDescription), null);
    }
2 Likes

Hi, @r.galewski.

Glad to know it works for you and thank you for sharing the solution (see issue) that other members of the community who might face the same challenges will know the answer.

Cheers,
Ian