Skip to content

Commit

Permalink
Sonar: Call async methods via an injected dependency instead of direc…
Browse files Browse the repository at this point in the history
…tly via 'this' (use Autowired & Lazy)
  • Loading branch information
qmonmert committed Oct 28, 2023
1 parent ec85d7e commit 438bc0a
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ import jakarta.mail.internet.MimeMessage;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.MessageSource;
import org.springframework.context.annotation.Lazy;
import org.springframework.mail.MailException;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.mail.javamail.MimeMessageHelper;
Expand Down Expand Up @@ -60,7 +62,9 @@ public class MailService {

private final SpringTemplateEngine templateEngine;

private final MailService self;
@Autowired
@Lazy
private MailService self;

public MailService(JHipsterProperties jHipsterProperties, JavaMailSender javaMailSender,
MessageSource messageSource, SpringTemplateEngine templateEngine) {
Expand All @@ -69,7 +73,6 @@ public class MailService {
this.javaMailSender = javaMailSender;
this.messageSource = messageSource;
this.templateEngine = templateEngine;
this.self = this;
}

@Async
Expand Down

0 comments on commit 438bc0a

Please sign in to comment.