Program: 58946
Project: 58946
Buggy source:
@Transactional(rollbackOn={MessagingException.class,IOException.class,Exception.class}) public Message sendByEmail(Message message) throws MessagingException, IOException {
  MailAccount mailAccount=message.getMailAccount();
  if (mailAccount == null) {
    return message;
  }
  LOG.debug("String_Node_Str");
  com.axelor.mail.MailAccount account=new SmtpAccount(mailAccount.getHost(),mailAccount.getPort().toString(),mailAccount.getLogin(),mailAccount.getPassword(),mailAccountService.getSmtpSecurity(mailAccount));
  List<String> replytoRecipients=this.getEmailAddresses(message.getReplyToEmailAddressSet()), toRecipients=this.getEmailAddresses(message.getToEmailAddressSet()), ccRecipients=this.getEmailAddresses(message.getCcEmailAddressSet()), bccRecipients=this.getEmailAddresses(message.getBccEmailAddressSet());
  MailSender sender=new MailSender(account);
  MailBuilder mailBuilder=sender.compose();
  mailBuilder.subject(message.getSubject());
  if (message.getFromEmailAddress() != null) {
    LOG.debug("String_Node_Str",message.getFromEmailAddress().getAddress());
    mailBuilder.from(message.getFromEmailAddress().getAddress());
  }
  if (replytoRecipients != null && !replytoRecipients.isEmpty()) {
    mailBuilder.replyTo(Joiner.on("String_Node_Str").join(toRecipients));
  }
  if (toRecipients != null && !toRecipients.isEmpty()) {
    mailBuilder.to(Joiner.on("String_Node_Str").join(toRecipients));
  }
  if (ccRecipients != null && !ccRecipients.isEmpty()) {
    mailBuilder.cc(Joiner.on("String_Node_Str").join(ccRecipients));
  }
  if (bccRecipients != null && !bccRecipients.isEmpty()) {
    mailBuilder.bcc(Joiner.on("String_Node_Str").join(bccRecipients));
  }
  if (!Strings.isNullOrEmpty(message.getContent())) {
    mailBuilder.html(message.getContent());
  }
  for (  MetaAttachment metaAttachment : getMetaAttachments(message)) {
    MetaFile metaFile=metaAttachment.getMetaFile();
    mailBuilder.attach(metaFile.getFileName(),MetaFiles.getPath(metaFile).toString());
  }
  mailBuilder.send();
  message.setSentByEmail(true);
  message.setStatusSelect(MessageRepository.STATUS_SENT);
  message.setSentDateT(LocalDateTime.now());
  return save(message);
}

Fixed version (ground truth):
@Transactional(rollbackOn={MessagingException.class,IOException.class,Exception.class}) public Message sendByEmail(Message message) throws MessagingException, IOException {
  MailAccount mailAccount=message.getMailAccount();
  if (mailAccount == null) {
    return message;
  }
  log.debug("String_Node_Str");
  com.axelor.mail.MailAccount account=new SmtpAccount(mailAccount.getHost(),mailAccount.getPort().toString(),mailAccount.getLogin(),mailAccount.getPassword(),mailAccountService.getSmtpSecurity(mailAccount));
  List<String> replytoRecipients=this.getEmailAddresses(message.getReplyToEmailAddressSet()), toRecipients=this.getEmailAddresses(message.getToEmailAddressSet()), ccRecipients=this.getEmailAddresses(message.getCcEmailAddressSet()), bccRecipients=this.getEmailAddresses(message.getBccEmailAddressSet());
  MailSender sender=new MailSender(account);
  MailBuilder mailBuilder=sender.compose();
  mailBuilder.subject(message.getSubject());
  if (message.getFromEmailAddress() != null) {
    log.debug("String_Node_Str",message.getFromEmailAddress().getAddress());
    mailBuilder.from(message.getFromEmailAddress().getAddress());
  }
  if (replytoRecipients != null && !replytoRecipients.isEmpty()) {
    mailBuilder.replyTo(Joiner.on("String_Node_Str").join(toRecipients));
  }
  if (toRecipients != null && !toRecipients.isEmpty()) {
    mailBuilder.to(Joiner.on("String_Node_Str").join(toRecipients));
  }
  if (ccRecipients != null && !ccRecipients.isEmpty()) {
    mailBuilder.cc(Joiner.on("String_Node_Str").join(ccRecipients));
  }
  if (bccRecipients != null && !bccRecipients.isEmpty()) {
    mailBuilder.bcc(Joiner.on("String_Node_Str").join(bccRecipients));
  }
  if (!Strings.isNullOrEmpty(message.getContent())) {
    mailBuilder.html(message.getContent());
  }
  for (  MetaAttachment metaAttachment : getMetaAttachments(message)) {
    MetaFile metaFile=metaAttachment.getMetaFile();
    mailBuilder.attach(metaFile.getFileName(),MetaFiles.getPath(metaFile).toString());
  }
  mailBuilder.send();
  message.setSentByEmail(true);
  message.setStatusSelect(MessageRepository.STATUS_SENT);
  message.setSentDateT(LocalDateTime.now());
  return save(message);
}