Inline User Macros sometimes don't render (velocity 2.0 needed) (JEMH-5536)

We've found that in high load situations, its possible for the Velocity render of content with inline macros to fail, resulting in unrendered macro content being sent to customers in the Subject or Body.

Root cause

The version of Velocity that Jira ships with has a bug VELOCITY-776, that surfaces due to how JEMH uses it.

We mitigated this problem in 2.1.5 for Jira 7.3+, to effectively render JEMH template content in single file, however, its possible that Jira could be using the Velocity renderer at the same time, again surfacing this bug.

Workarounds

Inline the macro content

Taking the macro content that you are trying to invoke and inlining it where required will avoid this bug.

Move (and possibly rename) macros into Jira macros.vm file

a) Export your JEMH User Macro definitions to a text file and append them to the Jira macros.vm ./atlassian-jira/WEB-INF/classes/templates/email/macros.vm
b) remove from User Macros in JEMH
c) restart Jira

The point of doing this is that the macros are then not 'inline'. We've had one other customer do this with favourable results, and is our current recommended workaround (the drawback is of course that changes to macros.vm cannot be done 'live', and need to be migrated as Jira is upgraded.

As this issue only affects addons that use inline macros. JRA-64947 has been logged.

JEMH next steps

Bundling our own Velocity Engine v2.0 inside JEMH seems appealing but is complex. This issue will aggregate that work.