Program: 172020
Project: 172020
Buggy source:
@SuppressWarnings("String_Node_Str") public void prepare(MimeMessage mimeMessage) throws MessagingException {
  if (logger.isDebugEnabled()) {
    logger.debug(ruleAction.getParameterValues());
  }
  messageRef[0]=new MimeMessageHelper(mimeMessage);
  if (headerEncoding != null && headerEncoding.length() != 0) {
    mimeMessage.setHeader("String_Node_Str",headerEncoding);
  }
  String to=(String)ruleAction.getParameterValue(PARAM_TO);
  String toRecipients=null;
  if (to != null && to.length() != 0) {
    messageRef[0].setTo(to);
    toRecipients=to;
    Serializable ccValue=(String)ruleAction.getParameterValue(PARAM_CC);
    if (ccValue != null) {
      if (ccValue instanceof String) {
        String cc=(String)ccValue;
        if (cc.length() > 0) {
          messageRef[0].setCc(cc);
        }
      }
 else       if (ccValue instanceof List<?>) {
        List<String> s=(List<String>)ccValue;
        messageRef[0].setCc((String[])s.toArray());
      }
 else       if (ccValue.getClass().isArray()) {
        messageRef[0].setCc((String[])ccValue);
      }
    }
    Serializable bccValue=(String)ruleAction.getParameterValue(PARAM_BCC);
    if (bccValue != null) {
      if (bccValue instanceof String) {
        String bcc=(String)bccValue;
        if (bcc.length() > 0) {
          messageRef[0].setBcc(bcc);
        }
      }
 else       if (bccValue instanceof List<?>) {
        List<String> s=(List<String>)bccValue;
        messageRef[0].setBcc((String[])s.toArray());
      }
 else       if (bccValue.getClass().isArray()) {
        messageRef[0].setCc((String[])bccValue);
      }
    }
  }
 else {
    Serializable authoritiesValue=ruleAction.getParameterValue(PARAM_TO_MANY);
    List<String> authorities=null;
    if (authoritiesValue != null) {
      if (authoritiesValue instanceof String) {
        authorities=new ArrayList<String>(1);
        authorities.add((String)authoritiesValue);
      }
 else {
        authorities=(List<String>)authoritiesValue;
      }
    }
    if (authorities != null && authorities.size() != 0) {
      List<String> recipients=new ArrayList<String>(authorities.size());
      if (logger.isTraceEnabled()) {
        logger.trace(authorities.size() + "String_Node_Str");
      }
      for (      String authority : authorities) {
        final AuthorityType authType=AuthorityType.getAuthorityType(authority);
        if (logger.isTraceEnabled()) {
          logger.trace("String_Node_Str" + authType);
        }
        if (authType.equals(AuthorityType.USER)) {
          if (personService.personExists(authority) == true) {
            NodeRef person=personService.getPerson(authority);
            if (!personService.isEnabled(authority) && !nodeService.hasAspect(person,ContentModel.ASPECT_ANULLABLE)) {
              continue;
            }
            String address=(String)nodeService.getProperty(person,ContentModel.PROP_EMAIL);
            if (address != null && address.length() != 0 && validateAddress(address)) {
              if (logger.isTraceEnabled()) {
                logger.trace("String_Node_Str");
              }
              recipients.add(address);
            }
 else {
              if (logger.isTraceEnabled()) {
                logger.trace("String_Node_Str");
              }
              if (validateAddress(authority)) {
                recipients.add(authority);
              }
            }
          }
 else {
            if (logger.isTraceEnabled()) {
              logger.trace("String_Node_Str");
            }
            if (validateAddress(authority)) {
              recipients.add(authority);
            }
          }
        }
 else         if (authType.equals(AuthorityType.GROUP) || authType.equals(AuthorityType.EVERYONE)) {
          if (logger.isTraceEnabled()) {
            logger.trace("String_Node_Str");
          }
          Set<String> users;
          if (authType.equals(AuthorityType.GROUP)) {
            users=authorityService.getContainedAuthorities(AuthorityType.USER,authority,false);
          }
 else {
            users=authorityService.getAllAuthorities(AuthorityType.USER);
          }
          for (          String userAuth : users) {
            if (personService.personExists(userAuth) == true) {
              if (!personService.isEnabled(userAuth)) {
                continue;
              }
              NodeRef person=personService.getPerson(userAuth);
              String address=(String)nodeService.getProperty(person,ContentModel.PROP_EMAIL);
              if (address != null && address.length() != 0) {
                recipients.add(address);
                if (logger.isTraceEnabled()) {
                  logger.trace("String_Node_Str");
                }
              }
 else {
                if (logger.isTraceEnabled()) {
                  logger.trace("String_Node_Str");
                }
                if (validateAddress(authority)) {
                  recipients.add(userAuth);
                }
              }
            }
 else {
              if (logger.isTraceEnabled()) {
                logger.trace("String_Node_Str");
              }
              if (validateAddress(authority)) {
                recipients.add(userAuth);
              }
            }
          }
        }
      }
      if (logger.isTraceEnabled()) {
        logger.trace(recipients.size() + "String_Node_Str");
      }
      if (recipients.size() > 0) {
        messageRef[0].setTo(recipients.toArray(new String[recipients.size()]));
        toRecipients=String.join("String_Node_Str",recipients);
      }
 else {
        throw new MailPreparationException("String_Node_Str");
      }
    }
 else {
      throw new MailPreparationException("String_Node_Str");
    }
  }
  NodeRef fromPerson=null;
  final String currentUserName=authService.getCurrentUserName();
  final List<String> usersNotToBeUsedInFromField=Arrays.asList(new String[]{AuthenticationUtil.getSystemUserName(),AuthenticationUtil.getGuestUserName()});
  if (!usersNotToBeUsedInFromField.contains(currentUserName)) {
    fromPerson=personService.getPerson(currentUserName);
  }
  if (isFromEnabled()) {
    String from=(String)ruleAction.getParameterValue(PARAM_FROM);
    if (from != null && from.length() > 0) {
      if (logger.isDebugEnabled()) {
        logger.debug("String_Node_Str" + from);
      }
      String fromPersonalName=(String)ruleAction.getParameterValue(PARAM_FROM_PERSONAL_NAME);
      if (fromPersonalName != null && fromPersonalName.length() > 0) {
        try {
          messageRef[0].setFrom(from,fromPersonalName);
        }
 catch (        UnsupportedEncodingException error) {
          messageRef[0].setFrom(from);
        }
      }
 else {
        messageRef[0].setFrom(from);
      }
    }
 else {
      String fromActualUser=null;
      if (fromPerson != null) {
        fromActualUser=(String)nodeService.getProperty(fromPerson,ContentModel.PROP_EMAIL);
      }
      if (fromActualUser != null && fromActualUser.length() != 0) {
        if (logger.isDebugEnabled()) {
          logger.debug("String_Node_Str" + fromPerson + "String_Node_Str"+ fromActualUser);
        }
        messageRef[0].setFrom(fromActualUser);
      }
 else {
        messageRef[0].setFrom(fromDefaultAddress);
      }
    }
  }
 else {
    if (logger.isDebugEnabled()) {
      logger.debug("String_Node_Str" + fromDefaultAddress);
    }
    messageRef[0].setFrom(fromDefaultAddress);
  }
  messageRef[0].setSubject((String)ruleAction.getParameterValue(PARAM_SUBJECT));
  if ((testModeRecipient != null) && (testModeRecipient.length() > 0) && (!testModeRecipient.equals("String_Node_Str"))) {
    messageRef[0].setTo(testModeRecipient);
    String emailRecipient=(String)ruleAction.getParameterValue(PARAM_TO);
    if (emailRecipient == null) {
      Object obj=ruleAction.getParameterValue(PARAM_TO_MANY);
      if (obj != null) {
        emailRecipient=obj.toString();
      }
    }
    String recipientPrefixedSubject="String_Node_Str" + emailRecipient + "String_Node_Str"+ (String)ruleAction.getParameterValue(PARAM_SUBJECT);
    messageRef[0].setSubject(recipientPrefixedSubject);
  }
  String text=null;
  Serializable ref=ruleAction.getParameterValue(PARAM_TEMPLATE);
  String templateRef=(ref instanceof NodeRef ? ((NodeRef)ref).toString() : (String)ref);
  if (templateRef != null) {
    Map<String,Object> suppliedModel=null;
    if (ruleAction.getParameterValue(PARAM_TEMPLATE_MODEL) != null) {
      Object m=ruleAction.getParameterValue(PARAM_TEMPLATE_MODEL);
      if (m instanceof Map) {
        suppliedModel=(Map<String,Object>)m;
      }
 else {
        logger.warn("String_Node_Str" + m.getClass().getName() + "String_Node_Str"+ m.toString());
      }
    }
    Map<String,Object> model=createEmailTemplateModel(actionedUponNodeRef,suppliedModel,fromPerson,toRecipients);
    Locale locale=recipient.getSecond();
    if (locale == null) {
      locale=(Locale)ruleAction.getParameterValue(PARAM_LOCALE);
    }
    if (locale == null) {
      locale=sender.getSecond();
    }
    String subject=(String)ruleAction.getParameterValue(PARAM_SUBJECT);
    Object subjectParamsObject=ruleAction.getParameterValue(PARAM_SUBJECT_PARAMS);
    Object[] subjectParams=null;
    if (subjectParamsObject instanceof List) {
      subjectParams=((List<Object>)subjectParamsObject).toArray();
    }
 else     if (subjectParamsObject instanceof Object[]) {
      subjectParams=(Object[])subjectParamsObject;
    }
 else {
      if (subjectParamsObject != null) {
        subjectParams=new Object[]{subjectParamsObject.toString()};
      }
    }
    String localizedSubject=getLocalizedSubject(subject,subjectParams,locale);
    if (locale == null) {
      text=templateService.processTemplate("String_Node_Str",templateRef,model);
    }
 else {
      text=templateService.processTemplate("String_Node_Str",templateRef,model,locale);
    }
    if ((testModeRecipient != null) && (testModeRecipient.length() > 0) && (!testModeRecipient.equals("String_Node_Str"))) {
      messageRef[0].setTo(testModeRecipient);
      String emailRecipient=recipient.getFirst();
      String recipientPrefixedSubject="String_Node_Str" + emailRecipient + "String_Node_Str"+ localizedSubject;
      messageRef[0].setSubject(recipientPrefixedSubject);
    }
 else {
      messageRef[0].setTo(recipient.getFirst());
      messageRef[0].setSubject(localizedSubject);
    }
  }
  boolean isHTML=false;
  if (text == null) {
    text=(String)ruleAction.getParameterValue(PARAM_TEXT);
  }
  if (text != null) {
    if (isHTML(text)) {
      isHTML=true;
    }
  }
 else {
    text=(String)ruleAction.getParameterValue(PARAM_HTML);
    if (text != null) {
      isHTML=true;
    }
  }
  if (text != null) {
    messageRef[0].setText(text,isHTML);
  }
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") public void prepare(MimeMessage mimeMessage) throws MessagingException {
  if (logger.isDebugEnabled()) {
    logger.debug(ruleAction.getParameterValues());
  }
  messageRef[0]=new MimeMessageHelper(mimeMessage);
  if (headerEncoding != null && headerEncoding.length() != 0) {
    mimeMessage.setHeader("String_Node_Str",headerEncoding);
  }
  String to=(String)ruleAction.getParameterValue(PARAM_TO);
  String toRecipients=null;
  if (to != null && to.length() != 0) {
    messageRef[0].setTo(to);
    toRecipients=to;
    Serializable ccValue=(Serializable)ruleAction.getParameterValue(PARAM_CC);
    if (ccValue != null) {
      if (ccValue instanceof String) {
        String cc=(String)ccValue;
        if (cc.length() > 0) {
          messageRef[0].setCc(cc);
        }
      }
 else       if (ccValue instanceof List<?>) {
        List<String> s=(List<String>)ccValue;
        messageRef[0].setCc(s.toArray(new String[s.size()]));
      }
 else       if (ccValue.getClass().isArray()) {
        messageRef[0].setCc((String[])ccValue);
      }
    }
    Serializable bccValue=(Serializable)ruleAction.getParameterValue(PARAM_BCC);
    if (bccValue != null) {
      if (bccValue instanceof String) {
        String bcc=(String)bccValue;
        if (bcc.length() > 0) {
          messageRef[0].setBcc(bcc);
        }
      }
 else       if (bccValue instanceof List<?>) {
        List<String> s=(List<String>)bccValue;
        messageRef[0].setBcc(s.toArray(new String[s.size()]));
      }
 else       if (bccValue.getClass().isArray()) {
        messageRef[0].setBcc((String[])bccValue);
      }
    }
  }
 else {
    Serializable authoritiesValue=ruleAction.getParameterValue(PARAM_TO_MANY);
    List<String> authorities=null;
    if (authoritiesValue != null) {
      if (authoritiesValue instanceof String) {
        authorities=new ArrayList<String>(1);
        authorities.add((String)authoritiesValue);
      }
 else {
        authorities=(List<String>)authoritiesValue;
      }
    }
    if (authorities != null && authorities.size() != 0) {
      List<String> recipients=new ArrayList<String>(authorities.size());
      if (logger.isTraceEnabled()) {
        logger.trace(authorities.size() + "String_Node_Str");
      }
      for (      String authority : authorities) {
        final AuthorityType authType=AuthorityType.getAuthorityType(authority);
        if (logger.isTraceEnabled()) {
          logger.trace("String_Node_Str" + authType);
        }
        if (authType.equals(AuthorityType.USER)) {
          if (personService.personExists(authority) == true) {
            NodeRef person=personService.getPerson(authority);
            if (!personService.isEnabled(authority) && !nodeService.hasAspect(person,ContentModel.ASPECT_ANULLABLE)) {
              continue;
            }
            String address=(String)nodeService.getProperty(person,ContentModel.PROP_EMAIL);
            if (address != null && address.length() != 0 && validateAddress(address)) {
              if (logger.isTraceEnabled()) {
                logger.trace("String_Node_Str");
              }
              recipients.add(address);
            }
 else {
              if (logger.isTraceEnabled()) {
                logger.trace("String_Node_Str");
              }
              if (validateAddress(authority)) {
                recipients.add(authority);
              }
            }
          }
 else {
            if (logger.isTraceEnabled()) {
              logger.trace("String_Node_Str");
            }
            if (validateAddress(authority)) {
              recipients.add(authority);
            }
          }
        }
 else         if (authType.equals(AuthorityType.GROUP) || authType.equals(AuthorityType.EVERYONE)) {
          if (logger.isTraceEnabled()) {
            logger.trace("String_Node_Str");
          }
          Set<String> users;
          if (authType.equals(AuthorityType.GROUP)) {
            users=authorityService.getContainedAuthorities(AuthorityType.USER,authority,false);
          }
 else {
            users=authorityService.getAllAuthorities(AuthorityType.USER);
          }
          for (          String userAuth : users) {
            if (personService.personExists(userAuth) == true) {
              if (!personService.isEnabled(userAuth)) {
                continue;
              }
              NodeRef person=personService.getPerson(userAuth);
              String address=(String)nodeService.getProperty(person,ContentModel.PROP_EMAIL);
              if (address != null && address.length() != 0) {
                recipients.add(address);
                if (logger.isTraceEnabled()) {
                  logger.trace("String_Node_Str");
                }
              }
 else {
                if (logger.isTraceEnabled()) {
                  logger.trace("String_Node_Str");
                }
                if (validateAddress(authority)) {
                  recipients.add(userAuth);
                }
              }
            }
 else {
              if (logger.isTraceEnabled()) {
                logger.trace("String_Node_Str");
              }
              if (validateAddress(authority)) {
                recipients.add(userAuth);
              }
            }
          }
        }
      }
      if (logger.isTraceEnabled()) {
        logger.trace(recipients.size() + "String_Node_Str");
      }
      if (recipients.size() > 0) {
        messageRef[0].setTo(recipients.toArray(new String[recipients.size()]));
        toRecipients=String.join("String_Node_Str",recipients);
      }
 else {
        throw new MailPreparationException("String_Node_Str");
      }
    }
 else {
      throw new MailPreparationException("String_Node_Str");
    }
  }
  NodeRef fromPerson=null;
  final String currentUserName=authService.getCurrentUserName();
  final List<String> usersNotToBeUsedInFromField=Arrays.asList(new String[]{AuthenticationUtil.getSystemUserName(),AuthenticationUtil.getGuestUserName()});
  if (!usersNotToBeUsedInFromField.contains(currentUserName)) {
    fromPerson=personService.getPerson(currentUserName);
  }
  if (isFromEnabled()) {
    String from=(String)ruleAction.getParameterValue(PARAM_FROM);
    if (from != null && from.length() > 0) {
      if (logger.isDebugEnabled()) {
        logger.debug("String_Node_Str" + from);
      }
      String fromPersonalName=(String)ruleAction.getParameterValue(PARAM_FROM_PERSONAL_NAME);
      if (fromPersonalName != null && fromPersonalName.length() > 0) {
        try {
          messageRef[0].setFrom(from,fromPersonalName);
        }
 catch (        UnsupportedEncodingException error) {
          messageRef[0].setFrom(from);
        }
      }
 else {
        messageRef[0].setFrom(from);
      }
    }
 else {
      String fromActualUser=null;
      if (fromPerson != null) {
        fromActualUser=(String)nodeService.getProperty(fromPerson,ContentModel.PROP_EMAIL);
      }
      if (fromActualUser != null && fromActualUser.length() != 0) {
        if (logger.isDebugEnabled()) {
          logger.debug("String_Node_Str" + fromPerson + "String_Node_Str"+ fromActualUser);
        }
        messageRef[0].setFrom(fromActualUser);
      }
 else {
        messageRef[0].setFrom(fromDefaultAddress);
      }
    }
  }
 else {
    if (logger.isDebugEnabled()) {
      logger.debug("String_Node_Str" + fromDefaultAddress);
    }
    messageRef[0].setFrom(fromDefaultAddress);
  }
  messageRef[0].setSubject((String)ruleAction.getParameterValue(PARAM_SUBJECT));
  if ((testModeRecipient != null) && (testModeRecipient.length() > 0) && (!testModeRecipient.equals("String_Node_Str"))) {
    messageRef[0].setTo(testModeRecipient);
    String emailRecipient=(String)ruleAction.getParameterValue(PARAM_TO);
    if (emailRecipient == null) {
      Object obj=ruleAction.getParameterValue(PARAM_TO_MANY);
      if (obj != null) {
        emailRecipient=obj.toString();
      }
    }
    String recipientPrefixedSubject="String_Node_Str" + emailRecipient + "String_Node_Str"+ (String)ruleAction.getParameterValue(PARAM_SUBJECT);
    messageRef[0].setSubject(recipientPrefixedSubject);
  }
  String text=null;
  Serializable ref=ruleAction.getParameterValue(PARAM_TEMPLATE);
  String templateRef=(ref instanceof NodeRef ? ((NodeRef)ref).toString() : (String)ref);
  if (templateRef != null) {
    Map<String,Object> suppliedModel=null;
    if (ruleAction.getParameterValue(PARAM_TEMPLATE_MODEL) != null) {
      Object m=ruleAction.getParameterValue(PARAM_TEMPLATE_MODEL);
      if (m instanceof Map) {
        suppliedModel=(Map<String,Object>)m;
      }
 else {
        logger.warn("String_Node_Str" + m.getClass().getName() + "String_Node_Str"+ m.toString());
      }
    }
    Map<String,Object> model=createEmailTemplateModel(actionedUponNodeRef,suppliedModel,fromPerson,toRecipients);
    Locale locale=recipient.getSecond();
    if (locale == null) {
      locale=(Locale)ruleAction.getParameterValue(PARAM_LOCALE);
    }
    if (locale == null) {
      locale=sender.getSecond();
    }
    String subject=(String)ruleAction.getParameterValue(PARAM_SUBJECT);
    Object subjectParamsObject=ruleAction.getParameterValue(PARAM_SUBJECT_PARAMS);
    Object[] subjectParams=null;
    if (subjectParamsObject instanceof List) {
      subjectParams=((List<Object>)subjectParamsObject).toArray();
    }
 else     if (subjectParamsObject instanceof Object[]) {
      subjectParams=(Object[])subjectParamsObject;
    }
 else {
      if (subjectParamsObject != null) {
        subjectParams=new Object[]{subjectParamsObject.toString()};
      }
    }
    String localizedSubject=getLocalizedSubject(subject,subjectParams,locale);
    if (locale == null) {
      text=templateService.processTemplate("String_Node_Str",templateRef,model);
    }
 else {
      text=templateService.processTemplate("String_Node_Str",templateRef,model,locale);
    }
    if ((testModeRecipient != null) && (testModeRecipient.length() > 0) && (!testModeRecipient.equals("String_Node_Str"))) {
      messageRef[0].setTo(testModeRecipient);
      String emailRecipient=recipient.getFirst();
      String recipientPrefixedSubject="String_Node_Str" + emailRecipient + "String_Node_Str"+ localizedSubject;
      messageRef[0].setSubject(recipientPrefixedSubject);
    }
 else {
      messageRef[0].setTo(recipient.getFirst());
      messageRef[0].setSubject(localizedSubject);
    }
  }
  boolean isHTML=false;
  if (text == null) {
    text=(String)ruleAction.getParameterValue(PARAM_TEXT);
  }
  if (text != null) {
    if (isHTML(text)) {
      isHTML=true;
    }
  }
 else {
    text=(String)ruleAction.getParameterValue(PARAM_HTML);
    if (text != null) {
      isHTML=true;
    }
  }
  if (text != null) {
    messageRef[0].setText(text,isHTML);
  }
}