TeslaCN commented on a change in pull request #1550:
URL: 
https://github.com/apache/shardingsphere-elasticjob/pull/1550#discussion_r503622106



##########
File path: 
elasticjob-error-handler/elasticjob-error-handler-type/elasticjob-error-handler-email/src/main/java/org/apache/shardingsphere/elasticjob/error/handler/email/EmailJobErrorHandler.java
##########
@@ -95,28 +96,35 @@ private String createErrorContext(final String jobName, 
final Throwable cause) {
         return String.format("Job '%s' exception occur in job processing, 
caused by %s", jobName, writer.toString());
     }
     
-    private Message createMessage(final String content) throws 
MessagingException {
-        MimeMessage result = new MimeMessage(session);
-        result.setFrom(new InternetAddress(config.getFrom()));
-        result.setSubject(config.getSubject());
+    private Message createMessage(final String content, final 
EmailConfiguration emailConfiguration) throws MessagingException {
+        MimeMessage result = new 
MimeMessage(createSession(emailConfiguration));

Review comment:
       Consider using `Optional.ofNullable(session).orElseGet(() -> 
createSession(emailConfiguration))` to prevent invoking synchronized method 
everytime. 




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to