Source:
<code>public Result execute() { final FormattingResultLog resultLog = new FormattingResultLog(); if (messageGatewayService == null) { resultLog.warn("MessageGatewayService OSGi service could not be found."); resultLog.info("Verify the Default Mail Service is active: http://localhost:4502/system/console/components/com.day.cq.mailer.impl.CqMailingService"); } else { final MessageGateway<SimpleEmail> messageGateway = messageGatewayService.getGateway(SimpleEmail.class); if (messageGateway == null) { resultLog.critical("The AEM Default Mail Service is INACTIVE, thus e-mails cannot be sent."); resultLog.info("Verify the Default Mail Service is active and configured: http://localhost:4502/system/console/components/com.day.cq.mailer.DefaultMailService"); log.error("Could not retrieve a SimpleEmail Message Gateway"); } else { try { List<InternetAddress> emailAddresses = new ArrayList<InternetAddress>(); emailAddresses.add(new InternetAddress(this.email)); MailTemplate mailTemplate = new MailTemplate(IOUtils.toInputStream(MAIL_TEMPLATE), CharEncoding.UTF_8); <START> SimpleEmail email = mailTemplate.getEmail(StrLookup.mapLookup(new HashMap<String, String>()), SimpleEmail.class); <END> email.setSubject("AEM E-mail Service Health Check"); email.setTo(emailAddresses); try { messageGateway.send(email); resultLog.info("The E-mail Service appears to be working properly. Verify the health check e-mail was sent to [ ]", this.email); } catch (Exception e) { resultLog.critical("Failed sending e-mail. Unable to send a test email via the configured E-mail server: " + e.getMessage(), e); log.error("Failed to send E-mail for E-mail Service health check", e); } logMailServiceConfig(resultLog, email); } catch (Exception e) { resultLog.healthCheckError("Sling Health check could not formulate a test email: " + e.getMessage(), e); log.error("Unable to execute E-mail health check", e); } } } return new Result(resultLog); }</code><technical_language>pick, Collections.emptyMap() optimized here</technical_language>

Target:
public Result execute() { final FormattingResultLog resultLog = new FormattingResultLog(); if (messageGatewayService == null) { resultLog.critical("MessageGatewayService OSGi service could not be found."); resultLog.info("Verify the Default Mail Service is active: http://<host>:<port>/system/console/components/com.day.cq.mailer.impl.CqMailingService"); } else { final MessageGateway<SimpleEmail> messageGateway = messageGatewayService.getGateway(SimpleEmail.class); if (messageGateway == null) { resultLog.critical("The AEM Default Mail Service is INACTIVE, thus e-mails cannot be sent."); resultLog.info("Verify the Default Mail Service is active and configured: http://<host>:<port>/system/console/components/com.day.cq.mailer.DefaultMailService"); log.warn("Could not retrieve a SimpleEmail Message Gateway"); } else { try { List<InternetAddress> emailAddresses = new ArrayList<InternetAddress>(); emailAddresses.add(new InternetAddress(this.email)); MailTemplate mailTemplate = new MailTemplate(IOUtils.toInputStream(MAIL_TEMPLATE), CharEncoding.UTF_8); SimpleEmail email = mailTemplate.getEmail(StrLookup.mapLookup(Collections.emptyMap()), SimpleEmail.class); email.setSubject("AEM E-mail Service Health Check"); email.setTo(emailAddresses); email.setSocketConnectionTimeout(TIMEOUT); email.setSocketTimeout(TIMEOUT); try { messageGateway.send(email); resultLog.info("The E-mail Service appears to be working properly. Verify the health check e-mail was sent to [ ]", this.email); } catch (Exception e) { resultLog.critical("Failed sending e-mail. Unable to send a test email via the configured E-mail server: " + e.getMessage(), e); log.warn("Failed to send E-mail for E-mail Service health check", e); } logMailServiceConfig(resultLog, email); } catch (Exception e) { resultLog.healthCheckError("Sling Health check could not formulate a test email: " + e.getMessage(), e); log.error("Unable to execute E-mail health check", e); } } } return new Result(resultLog); }