Skip to content

Commit

Permalink
[2.26.x] DDF-6609 corrects email audit logging (#6610)
Browse files Browse the repository at this point in the history
  • Loading branch information
jlcsmith authored Aug 18, 2021
1 parent f2912d4 commit a3eda50
Showing 1 changed file with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -168,23 +168,28 @@ public Session createSession() {
@Override
public Future<Void> send(Message message) {
notNull(message, "message must be non-null");
try {
securityLogger.audit(
"Sending email: recipient={} subject={}",
Arrays.toString(message.getAllRecipients()),
message.getSubject());
} catch (MessagingException e) {
securityLogger.auditWarn("Unable to audit log email", e);
}

return executorService.submit(
() -> {
final ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(Transport.class.getClassLoader());
try {
Transport.send(message);
} catch (MessagingException e) {
LOGGER.debug("Could not send message {}", message, e);
LOGGER.warn("Could not send message {}", message, e);
return null;
} finally {
Thread.currentThread().setContextClassLoader(classLoader);
}

securityLogger.audit(
"Sent an email: recipient={} subject={}",
Arrays.toString(message.getAllRecipients()),
message.getSubject());
return null;
});
}
Expand Down

0 comments on commit a3eda50

Please sign in to comment.