diff --git a/src/main/java/org/worldcubeassociation/dbsanitycheck/service/impl/EmailServiceImpl.java b/src/main/java/org/worldcubeassociation/dbsanitycheck/service/impl/EmailServiceImpl.java index fe29768..ceffdc1 100644 --- a/src/main/java/org/worldcubeassociation/dbsanitycheck/service/impl/EmailServiceImpl.java +++ b/src/main/java/org/worldcubeassociation/dbsanitycheck/service/impl/EmailServiceImpl.java @@ -45,7 +45,7 @@ public class EmailServiceImpl implements EmailService { public void sendEmail(String emailTo, List analysisResult, List queriesWithError) throws MessagingException { - if (sendMail) { + if (sendMail && emailTo.length() > 0) { log.info("Sending email with the analysis"); MimeMessage message = emailSender.createMimeMessage(); diff --git a/src/main/java/org/worldcubeassociation/dbsanitycheck/service/impl/WrtSanityCheckServiceImpl.java b/src/main/java/org/worldcubeassociation/dbsanitycheck/service/impl/WrtSanityCheckServiceImpl.java index e53bd07..c1827e6 100644 --- a/src/main/java/org/worldcubeassociation/dbsanitycheck/service/impl/WrtSanityCheckServiceImpl.java +++ b/src/main/java/org/worldcubeassociation/dbsanitycheck/service/impl/WrtSanityCheckServiceImpl.java @@ -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; @@ -47,7 +48,7 @@ public void execute() throws MessagingException { log.info("Found {} queries", sanityChecks.size()); Map> 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> entry : sanityChecksByEmail.entrySet()) {