Program: 69527
Project: 69527
Buggy source:
/** 
 * Internal helper - does all the magic
 * @param group
 * @param actor
 * @param subjectKey
 * @param bodyKey
 * @return
 */
private static MailTemplate createMailTemplate(BusinessGroupShort group,Identity actor,String subjectKey,String bodyKey){
  String[] bodyArgs=new String[]{actor.getUser().getProperty(UserConstants.FIRSTNAME,null),actor.getUser().getProperty(UserConstants.LASTNAME,null),actor.getUser().getProperty(UserConstants.EMAIL,null),actor.getUser().getProperty(UserConstants.EMAIL,null)};
  Locale locale=I18nManager.getInstance().getLocaleOrDefault(actor.getUser().getPreferences().getLanguage());
  Translator trans=Util.createPackageTranslator(BGMailHelper.class,locale,Util.createPackageTranslator(BusinessGroupListController.class,locale));
  String subject=trans.translate(subjectKey);
  String body=trans.translate(bodyKey,bodyArgs);
  final String courselist;
  final String groupname;
  final String groupdescription;
  StringBuilder learningResources=new StringBuilder();
  if (group != null) {
    BusinessGroupService businessGroupService=CoreSpringFactory.getImpl(BusinessGroupService.class);
    List<RepositoryEntryShort> repoEntries=businessGroupService.findShortRepositoryEntries(Collections.singletonList(group),0,-1);
    for (    RepositoryEntryShort entry : repoEntries) {
      String title=entry.getDisplayname();
      String url=BusinessControlFactory.getInstance().getURLFromBusinessPathString("String_Node_Str" + entry.getKey() + "String_Node_Str");
      learningResources.append(title);
      learningResources.append("String_Node_Str");
      learningResources.append(url);
      learningResources.append("String_Node_Str");
    }
    courselist=learningResources.toString();
    groupname=group.getName();
    groupdescription=(group instanceof BusinessGroup ? FilterFactory.getHtmlTagAndDescapingFilter().filter(((BusinessGroup)group).getDescription()) : "String_Node_Str");
    subject=subject.replaceAll("String_Node_Str",groupname == null ? "String_Node_Str" : groupname);
    body=body.replaceAll("String_Node_Str",groupname == null ? "String_Node_Str" : groupname);
    body=body.replaceAll("String_Node_Str",groupdescription == null ? "String_Node_Str" : groupdescription);
    body=body.replaceAll("String_Node_Str",courselist == null ? "String_Node_Str" : courselist);
  }
 else {
    courselist="String_Node_Str";
    groupname="String_Node_Str";
    groupdescription="String_Node_Str";
  }
  MailTemplate mailTempl=new MailTemplate(subject,body,null){
    @Override public void putVariablesInMailContext(    VelocityContext context,    Identity identity){
      User user=identity.getUser();
      context.put("String_Node_Str",user.getProperty(UserConstants.FIRSTNAME,null));
      context.put("String_Node_Str",user.getProperty(UserConstants.LASTNAME,null));
      context.put("String_Node_Str",user.getProperty(UserConstants.EMAIL,null));
      context.put("String_Node_Str",groupname);
      context.put("String_Node_Str",groupdescription);
      context.put("String_Node_Str",courselist);
    }
  }
;
  return mailTempl;
}

Fixed version (ground truth):
/** 
 * Internal helper - does all the magic
 * @param group
 * @param actor
 * @param subjectKey
 * @param bodyKey
 * @return
 */
private static MailTemplate createMailTemplate(BusinessGroupShort group,Identity actor,String subjectKey,String bodyKey){
  String[] bodyArgs=new String[]{actor.getUser().getProperty(UserConstants.FIRSTNAME,null),actor.getUser().getProperty(UserConstants.LASTNAME,null),actor.getUser().getProperty(UserConstants.EMAIL,null),actor.getUser().getProperty(UserConstants.EMAIL,null)};
  Locale locale=I18nManager.getInstance().getLocaleOrDefault(actor.getUser().getPreferences().getLanguage());
  Translator trans=Util.createPackageTranslator(BGMailHelper.class,locale,Util.createPackageTranslator(BusinessGroupListController.class,locale));
  String subject=trans.translate(subjectKey);
  String body=trans.translate(bodyKey,bodyArgs);
  final String courselist;
  final String groupname;
  final String groupdescription;
  StringBuilder learningResources=new StringBuilder();
  if (group != null) {
    BusinessGroupService businessGroupService=CoreSpringFactory.getImpl(BusinessGroupService.class);
    List<RepositoryEntryShort> repoEntries=businessGroupService.findShortRepositoryEntries(Collections.singletonList(group),0,-1);
    for (    RepositoryEntryShort entry : repoEntries) {
      String title=entry.getDisplayname();
      String url=BusinessControlFactory.getInstance().getURLFromBusinessPathString("String_Node_Str" + entry.getKey() + "String_Node_Str");
      learningResources.append(title);
      learningResources.append("String_Node_Str");
      learningResources.append(url);
      learningResources.append("String_Node_Str");
    }
    courselist=learningResources.toString();
    groupname=group.getName();
    groupdescription=(group instanceof BusinessGroup ? FilterFactory.getHtmlTagAndDescapingFilter().filter(((BusinessGroup)group).getDescription()) : "String_Node_Str");
    subject=subject.replace("String_Node_Str",groupname == null ? "String_Node_Str" : groupname);
    body=body.replace("String_Node_Str",groupname == null ? "String_Node_Str" : groupname);
    body=body.replace("String_Node_Str",groupdescription == null ? "String_Node_Str" : groupdescription);
    body=body.replace("String_Node_Str",courselist == null ? "String_Node_Str" : courselist);
  }
 else {
    courselist="String_Node_Str";
    groupname="String_Node_Str";
    groupdescription="String_Node_Str";
  }
  MailTemplate mailTempl=new MailTemplate(subject,body,null){
    @Override public void putVariablesInMailContext(    VelocityContext context,    Identity identity){
      User user=identity.getUser();
      context.put("String_Node_Str",user.getProperty(UserConstants.FIRSTNAME,null));
      context.put("String_Node_Str",user.getProperty(UserConstants.LASTNAME,null));
      context.put("String_Node_Str",user.getProperty(UserConstants.EMAIL,null));
      context.put("String_Node_Str",groupname);
      context.put("String_Node_Str",groupdescription);
      context.put("String_Node_Str",courselist);
    }
  }
;
  return mailTempl;
}