Skip to content

Commit

Permalink
Handle empty email to case
Browse files Browse the repository at this point in the history
  • Loading branch information
campos20 committed Jul 24, 2023
1 parent 12290dc commit 3fe23bd
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public class EmailServiceImpl implements EmailService {
public void sendEmail(String emailTo, List<AnalysisBean> analysisResult,
List<SanityCheckWithErrorBean> queriesWithError)
throws MessagingException {
if (sendMail) {
if (sendMail && emailTo.length() > 0) {
log.info("Sending email with the analysis");

MimeMessage message = emailSender.createMimeMessage();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.stream.Collectors;
import javax.mail.MessagingException;

Expand Down Expand Up @@ -47,7 +48,7 @@ public void execute() throws MessagingException {
log.info("Found {} queries", sanityChecks.size());

Map<String, List<SanityCheck>> sanityChecksByEmail = sanityChecks.stream()
.collect(Collectors.groupingBy(s -> s.getCategory().getEmailTo()));
.collect(Collectors.groupingBy(s -> Optional.ofNullable(s.getCategory().getEmailTo()).orElse("")));
log.info("Found {} emails", sanityChecksByEmail.size());

for (Map.Entry<String, List<SanityCheck>> entry : sanityChecksByEmail.entrySet()) {
Expand Down

0 comments on commit 3fe23bd

Please sign in to comment.