Alex Earl commented on Bug JENKINS-20078

hudson.plugins.emailext.* (mainly ExtendedEmailPublisher and EmailRecipientUtils)
hudson.plugins.emailext.plugins.* (mainly ContentBuilder)
org.jenkinsci.plugins.tokenmacro.*

The only thing I changed in the release was adding caching. Perhaps my caching implementation wasn't a good one.

public class ContentBuilder {

    @CopyOnWrite
    private static volatile List<TokenMacro> privateMacros;
    ...

    public String transformText(String origText, ExtendedEmailPublisherContext context, List<TokenMacro> additionalMacros) {
    ....
       try {
           List<TokenMacro> privMacros = getPrivateMacros();
           if(additionalMacros != null)
               privateMacros.addAll(additionalMacros);
           newText = TokenMacro.expandAll(context.getBuild(), context.getListener(), newText, false, privMacros);
       } catch (MacroEvaluationException e) {
           context.getListener().getLogger().println("Error evaluating token: " + e.getMessage());
       } catch (Exception e) {
           Logger.getLogger(ContentBuilder.class.getName()).log(Level.SEVERE, null, e);
       }
    ...
    }

    public static List<TokenMacro> getPrivateMacros() {
        if(privateMacros != null)
            return privateMacros;

        privateMacros = new ArrayList<TokenMacro>();
        ClassLoader cl = Jenkins.getInstance().pluginManager.uberClassLoader;
        for (final IndexItem<EmailToken, TokenMacro> item : Index.load(EmailToken.class, TokenMacro.class, cl)) {
            try {
                privateMacros.add(item.instance());
            } catch (Exception e) {
                // ignore errors loading tokens
            }
        }
        return privateMacros;
    }
}

I'm not a Java guy really, so if there is a better way to do it in Java, please give me some pointers.

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators.
For more information on JIRA, see: http://www.atlassian.com/software/jira

--
You received this message because you are subscribed to the Google Groups "Jenkins Issues" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to