You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2020/09/21 08:31:44 UTC

[GitHub] [shardingsphere-elasticjob] luky116 opened a new pull request #1474: 1440

luky116 opened a new pull request #1474:
URL: https://github.com/apache/shardingsphere-elasticjob/pull/1474


   Fixes #1440 .
   
   Changes proposed in this pull request:
   - add email job handler
   -
   -
   


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [shardingsphere-elasticjob] luky116 commented on pull request #1474: Add EmailJobErrorHandler to support sending email when job error

Posted by GitBox <gi...@apache.org>.
luky116 commented on pull request #1474:
URL: https://github.com/apache/shardingsphere-elasticjob/pull/1474#issuecomment-695982231


   > Can you change the title?
   
   I'll change it


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [shardingsphere-elasticjob] terrymanu commented on pull request #1474: 1440

Posted by GitBox <gi...@apache.org>.
terrymanu commented on pull request #1474:
URL: https://github.com/apache/shardingsphere-elasticjob/pull/1474#issuecomment-695979044


   Can you change the title?


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [shardingsphere-elasticjob] vran-dev commented on a change in pull request #1474: Add EmailJobErrorHandler to support sending email when job error

Posted by GitBox <gi...@apache.org>.
vran-dev commented on a change in pull request #1474:
URL: https://github.com/apache/shardingsphere-elasticjob/pull/1474#discussion_r492151949



##########
File path: elasticjob-error-handler/elasticjob-error-handler-email/src/main/java/org/apache/shardingsphere/elasticjob/error/handler/email/EmailJobErrorHandler.java
##########
@@ -0,0 +1,126 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.elasticjob.error.handler.email;
+
+import com.google.common.base.Preconditions;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.shardingsphere.elasticjob.error.handler.JobErrorHandler;
+
+import javax.mail.Authenticator;
+import javax.mail.BodyPart;
+import javax.mail.Message;
+import javax.mail.MessagingException;
+import javax.mail.Multipart;
+import javax.mail.PasswordAuthentication;
+import javax.mail.Session;
+import javax.mail.Transport;
+import javax.mail.internet.InternetAddress;
+import javax.mail.internet.MimeBodyPart;
+import javax.mail.internet.MimeMessage;
+import javax.mail.internet.MimeMultipart;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.util.Date;
+import java.util.Properties;
+
+/**
+ * Job error handler for sending error message by email.
+ */
+@Slf4j
+public final class EmailJobErrorHandler implements JobErrorHandler {
+    
+    public static final String CONFIG_PREFIX = "email";
+    
+    private EmailConfiguration emailConfiguration;
+    
+    private Session session;
+    
+    public EmailJobErrorHandler() {
+        loadConfiguration();
+    }
+    
+    @Override
+    public void handleException(final String jobName, final Throwable cause) {
+        try {
+            Preconditions.checkNotNull(emailConfiguration);
+            String content = buildContent(jobName, cause);
+            Message message = buildMessage(content);
+            sendMessage(message);
+        } catch (final NullPointerException | MessagingException ex) {
+            log.error("Elastic job: email job handler error", ex);
+        }

Review comment:
       hello, I hava some suggestions you can refre to.
   
   if `emailConfiguration` is null means do nothing, i think use `check and  (log?) return`  is better than `check and catch`,  because
    1.  code taste: manually check and catch could increased code complexity
    2.  performance:  avoid use exception as control flow




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [shardingsphere-elasticjob] terrymanu commented on pull request #1474: 1440

Posted by GitBox <gi...@apache.org>.
terrymanu commented on pull request #1474:
URL: https://github.com/apache/shardingsphere-elasticjob/pull/1474#issuecomment-695979044


   Can you change the title?


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [shardingsphere-elasticjob] luky116 commented on a change in pull request #1474: Add EmailJobErrorHandler to support sending email when job error

Posted by GitBox <gi...@apache.org>.
luky116 commented on a change in pull request #1474:
URL: https://github.com/apache/shardingsphere-elasticjob/pull/1474#discussion_r491880610



##########
File path: elasticjob-error-handler/elasticjob-error-handler-email/src/main/java/org/apache/shardingsphere/elasticjob/error/handler/email/EmailJobErrorHandler.java
##########
@@ -0,0 +1,126 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.elasticjob.error.handler.email;
+
+import com.google.common.base.Preconditions;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.shardingsphere.elasticjob.error.handler.JobErrorHandler;
+
+import javax.mail.Authenticator;
+import javax.mail.BodyPart;
+import javax.mail.Message;
+import javax.mail.MessagingException;
+import javax.mail.Multipart;
+import javax.mail.PasswordAuthentication;
+import javax.mail.Session;
+import javax.mail.Transport;
+import javax.mail.internet.InternetAddress;
+import javax.mail.internet.MimeBodyPart;
+import javax.mail.internet.MimeMessage;
+import javax.mail.internet.MimeMultipart;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.util.Date;
+import java.util.Properties;
+
+/**
+ * Job error handler for sending error message by email.
+ */
+@Slf4j
+public final class EmailJobErrorHandler implements JobErrorHandler {
+    
+    public static final String CONFIG_PREFIX = "email";
+    
+    private EmailConfiguration emailConfiguration;
+    
+    private Session session;
+    
+    public EmailJobErrorHandler() {
+        loadConfiguration();
+    }
+    
+    @Override
+    public void handleException(final String jobName, final Throwable cause) {
+        try {
+            Preconditions.checkNotNull(emailConfiguration);
+            String content = buildContent(jobName, cause);
+            Message message = buildMessage(content);
+            sendMessage(message);
+        } catch (final NullPointerException | MessagingException ex) {
+            log.error("Elastic job: email job handler error", ex);
+        }

Review comment:
       if user don't set email configuration, `Preconditions.checkNotNull(emailConfiguration)` will throws NullPointerException,it menas user don't want email handler. So here will catch NullPointerException.




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [shardingsphere-elasticjob] luky116 closed pull request #1474: Add EmailJobErrorHandler to support sending email when job error

Posted by GitBox <gi...@apache.org>.
luky116 closed pull request #1474:
URL: https://github.com/apache/shardingsphere-elasticjob/pull/1474


   


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [shardingsphere-elasticjob] TeslaCN commented on a change in pull request #1474: Add EmailJobErrorHandler to support sending email when job error

Posted by GitBox <gi...@apache.org>.
TeslaCN commented on a change in pull request #1474:
URL: https://github.com/apache/shardingsphere-elasticjob/pull/1474#discussion_r491873382



##########
File path: elasticjob-error-handler/elasticjob-error-handler-email/src/main/java/org/apache/shardingsphere/elasticjob/error/handler/email/ConfigurationLoader.java
##########
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.elasticjob.error.handler.email;
+
+import lombok.NoArgsConstructor;
+import org.apache.shardingsphere.elasticjob.infra.yaml.YamlEngine;
+
+import java.io.InputStream;
+
+/**
+ * Job error configuration loader.
+ */
+@NoArgsConstructor

Review comment:
       "Private" access required.

##########
File path: elasticjob-error-handler/elasticjob-error-handler-email/pom.xml
##########
@@ -27,4 +27,38 @@
     </parent>
     
     <artifactId>elasticjob-error-handler-email</artifactId>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.shardingsphere.elasticjob</groupId>
+            <artifactId>elasticjob-error-handler-general</artifactId>
+            <version>${project.parent.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.projectlombok</groupId>
+            <artifactId>lombok</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>com.sun.mail</groupId>
+            <artifactId>javax.mail</artifactId>
+            <version>1.6.0</version>
+        </dependency>
+
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.mockito</groupId>
+            <artifactId>mockito-core</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.mockito</groupId>
+            <artifactId>mockito-inline</artifactId>
+        </dependency>

Review comment:
       "Test" scope is required.

##########
File path: elasticjob-error-handler/elasticjob-error-handler-general/src/main/java/org/apache/shardingsphere/elasticjob/error/handler/JobErrorHandlerFactory.java
##########
@@ -56,5 +56,5 @@ public static JobErrorHandler getHandler(final String type) {
             throw new JobConfigurationException("Can not find job error handler type '%s'.", type);
         }
         return HANDLERS.get(type);
-    } 
+    }

Review comment:
       Unnecessary changes.

##########
File path: elasticjob-error-handler/elasticjob-error-handler-general/src/test/java/org/apache/shardingsphere/elasticjob/error/handler/JobErrorHandlerFactoryTest.java
##########
@@ -7,7 +7,7 @@
  * the License.  You may obtain a copy of the License at
  *
  *     http://www.apache.org/licenses/LICENSE-2.0
- *  
+ *

Review comment:
       Unnecessary changes.

##########
File path: elasticjob-error-handler/elasticjob-error-handler-email/src/main/java/org/apache/shardingsphere/elasticjob/error/handler/email/EmailJobErrorHandler.java
##########
@@ -0,0 +1,126 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.elasticjob.error.handler.email;
+
+import com.google.common.base.Preconditions;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.shardingsphere.elasticjob.error.handler.JobErrorHandler;
+
+import javax.mail.Authenticator;
+import javax.mail.BodyPart;
+import javax.mail.Message;
+import javax.mail.MessagingException;
+import javax.mail.Multipart;
+import javax.mail.PasswordAuthentication;
+import javax.mail.Session;
+import javax.mail.Transport;
+import javax.mail.internet.InternetAddress;
+import javax.mail.internet.MimeBodyPart;
+import javax.mail.internet.MimeMessage;
+import javax.mail.internet.MimeMultipart;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.util.Date;
+import java.util.Properties;
+
+/**
+ * Job error handler for sending error message by email.
+ */
+@Slf4j
+public final class EmailJobErrorHandler implements JobErrorHandler {
+    
+    public static final String CONFIG_PREFIX = "email";
+    
+    private EmailConfiguration emailConfiguration;
+    
+    private Session session;
+    
+    public EmailJobErrorHandler() {
+        loadConfiguration();
+    }
+    
+    @Override
+    public void handleException(final String jobName, final Throwable cause) {
+        try {
+            Preconditions.checkNotNull(emailConfiguration);
+            String content = buildContent(jobName, cause);
+            Message message = buildMessage(content);
+            sendMessage(message);
+        } catch (final NullPointerException | MessagingException ex) {
+            log.error("Elastic job: email job handler error", ex);
+        }

Review comment:
       Catch 'NullPointerException' seems weird.

##########
File path: elasticjob-error-handler/elasticjob-error-handler-general/src/test/java/org/apache/shardingsphere/elasticjob/error/handler/impl/IgnoreJobErrorHandlerTest.java
##########
@@ -20,7 +20,7 @@
 import org.junit.Test;
 
 public final class IgnoreJobErrorHandlerTest {
-    
+

Review comment:
       Unnecessary changes.

##########
File path: elasticjob-error-handler/elasticjob-error-handler-email/src/main/resources/META-INF/services/org.apache.shardingsphere.elasticjob.error.handler.JobErrorHandler
##########
@@ -15,6 +15,4 @@
 # limitations under the License.
 #
 
-org.apache.shardingsphere.elasticjob.infra.handler.error.impl.LogJobErrorHandler
-org.apache.shardingsphere.elasticjob.infra.handler.error.impl.IgnoreJobErrorHandler
-org.apache.shardingsphere.elasticjob.infra.handler.error.impl.ThrowJobErrorHandler
+org.apache.shardingsphere.elasticjob.error.handler.email.EmailJobErrorHandler

Review comment:
       Need a blank line.

##########
File path: elasticjob-error-handler/elasticjob-error-handler-general/src/test/java/org/apache/shardingsphere/elasticjob/error/handler/impl/IgnoreJobErrorHandlerTest.java
##########
@@ -7,7 +7,7 @@
  * the License.  You may obtain a copy of the License at
  *
  *     http://www.apache.org/licenses/LICENSE-2.0
- *  
+ *

Review comment:
       Unnecessary changes.




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [shardingsphere-elasticjob] luky116 commented on a change in pull request #1474: Add EmailJobErrorHandler to support sending email when job error

Posted by GitBox <gi...@apache.org>.
luky116 commented on a change in pull request #1474:
URL: https://github.com/apache/shardingsphere-elasticjob/pull/1474#discussion_r491880610



##########
File path: elasticjob-error-handler/elasticjob-error-handler-email/src/main/java/org/apache/shardingsphere/elasticjob/error/handler/email/EmailJobErrorHandler.java
##########
@@ -0,0 +1,126 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.elasticjob.error.handler.email;
+
+import com.google.common.base.Preconditions;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.shardingsphere.elasticjob.error.handler.JobErrorHandler;
+
+import javax.mail.Authenticator;
+import javax.mail.BodyPart;
+import javax.mail.Message;
+import javax.mail.MessagingException;
+import javax.mail.Multipart;
+import javax.mail.PasswordAuthentication;
+import javax.mail.Session;
+import javax.mail.Transport;
+import javax.mail.internet.InternetAddress;
+import javax.mail.internet.MimeBodyPart;
+import javax.mail.internet.MimeMessage;
+import javax.mail.internet.MimeMultipart;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.util.Date;
+import java.util.Properties;
+
+/**
+ * Job error handler for sending error message by email.
+ */
+@Slf4j
+public final class EmailJobErrorHandler implements JobErrorHandler {
+    
+    public static final String CONFIG_PREFIX = "email";
+    
+    private EmailConfiguration emailConfiguration;
+    
+    private Session session;
+    
+    public EmailJobErrorHandler() {
+        loadConfiguration();
+    }
+    
+    @Override
+    public void handleException(final String jobName, final Throwable cause) {
+        try {
+            Preconditions.checkNotNull(emailConfiguration);
+            String content = buildContent(jobName, cause);
+            Message message = buildMessage(content);
+            sendMessage(message);
+        } catch (final NullPointerException | MessagingException ex) {
+            log.error("Elastic job: email job handler error", ex);
+        }

Review comment:
       if user don't set email configuration, Preconditions.checkNotNull(emailConfiguration) will throws NullPointerException,it menas user don't want email handler. So here will catch NullPointerException.




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [shardingsphere-elasticjob] vran-dev commented on a change in pull request #1474: Add EmailJobErrorHandler to support sending email when job error

Posted by GitBox <gi...@apache.org>.
vran-dev commented on a change in pull request #1474:
URL: https://github.com/apache/shardingsphere-elasticjob/pull/1474#discussion_r492151949



##########
File path: elasticjob-error-handler/elasticjob-error-handler-email/src/main/java/org/apache/shardingsphere/elasticjob/error/handler/email/EmailJobErrorHandler.java
##########
@@ -0,0 +1,126 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.elasticjob.error.handler.email;
+
+import com.google.common.base.Preconditions;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.shardingsphere.elasticjob.error.handler.JobErrorHandler;
+
+import javax.mail.Authenticator;
+import javax.mail.BodyPart;
+import javax.mail.Message;
+import javax.mail.MessagingException;
+import javax.mail.Multipart;
+import javax.mail.PasswordAuthentication;
+import javax.mail.Session;
+import javax.mail.Transport;
+import javax.mail.internet.InternetAddress;
+import javax.mail.internet.MimeBodyPart;
+import javax.mail.internet.MimeMessage;
+import javax.mail.internet.MimeMultipart;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.util.Date;
+import java.util.Properties;
+
+/**
+ * Job error handler for sending error message by email.
+ */
+@Slf4j
+public final class EmailJobErrorHandler implements JobErrorHandler {
+    
+    public static final String CONFIG_PREFIX = "email";
+    
+    private EmailConfiguration emailConfiguration;
+    
+    private Session session;
+    
+    public EmailJobErrorHandler() {
+        loadConfiguration();
+    }
+    
+    @Override
+    public void handleException(final String jobName, final Throwable cause) {
+        try {
+            Preconditions.checkNotNull(emailConfiguration);
+            String content = buildContent(jobName, cause);
+            Message message = buildMessage(content);
+            sendMessage(message);
+        } catch (final NullPointerException | MessagingException ex) {
+            log.error("Elastic job: email job handler error", ex);
+        }

Review comment:
       hello, I hava some suggestions you can refre to.
   
   if `emailConfiguration` is null means do nothing, i think use `check and  (log?) return`  is better than `check and catch`,  because
    1.  code taste: manually check and catch could increased code complexity
    2.  performance:  avoid use exception as control flow




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [shardingsphere-elasticjob] luky116 commented on pull request #1474: Add EmailJobErrorHandler to support sending email when job error

Posted by GitBox <gi...@apache.org>.
luky116 commented on pull request #1474:
URL: https://github.com/apache/shardingsphere-elasticjob/pull/1474#issuecomment-695982231


   > Can you change the title?
   
   I'll change it


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [shardingsphere-elasticjob] luky116 commented on a change in pull request #1474: Add EmailJobErrorHandler to support sending email when job error

Posted by GitBox <gi...@apache.org>.
luky116 commented on a change in pull request #1474:
URL: https://github.com/apache/shardingsphere-elasticjob/pull/1474#discussion_r491880610



##########
File path: elasticjob-error-handler/elasticjob-error-handler-email/src/main/java/org/apache/shardingsphere/elasticjob/error/handler/email/EmailJobErrorHandler.java
##########
@@ -0,0 +1,126 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.elasticjob.error.handler.email;
+
+import com.google.common.base.Preconditions;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.shardingsphere.elasticjob.error.handler.JobErrorHandler;
+
+import javax.mail.Authenticator;
+import javax.mail.BodyPart;
+import javax.mail.Message;
+import javax.mail.MessagingException;
+import javax.mail.Multipart;
+import javax.mail.PasswordAuthentication;
+import javax.mail.Session;
+import javax.mail.Transport;
+import javax.mail.internet.InternetAddress;
+import javax.mail.internet.MimeBodyPart;
+import javax.mail.internet.MimeMessage;
+import javax.mail.internet.MimeMultipart;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.util.Date;
+import java.util.Properties;
+
+/**
+ * Job error handler for sending error message by email.
+ */
+@Slf4j
+public final class EmailJobErrorHandler implements JobErrorHandler {
+    
+    public static final String CONFIG_PREFIX = "email";
+    
+    private EmailConfiguration emailConfiguration;
+    
+    private Session session;
+    
+    public EmailJobErrorHandler() {
+        loadConfiguration();
+    }
+    
+    @Override
+    public void handleException(final String jobName, final Throwable cause) {
+        try {
+            Preconditions.checkNotNull(emailConfiguration);
+            String content = buildContent(jobName, cause);
+            Message message = buildMessage(content);
+            sendMessage(message);
+        } catch (final NullPointerException | MessagingException ex) {
+            log.error("Elastic job: email job handler error", ex);
+        }

Review comment:
       if user don't set email configuration, Preconditions.checkNotNull(emailConfiguration) will throws NullPointerException,it menas user don't want email handler. So here will catch NullPointerException.

##########
File path: elasticjob-error-handler/elasticjob-error-handler-email/src/main/java/org/apache/shardingsphere/elasticjob/error/handler/email/EmailJobErrorHandler.java
##########
@@ -0,0 +1,126 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.elasticjob.error.handler.email;
+
+import com.google.common.base.Preconditions;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.shardingsphere.elasticjob.error.handler.JobErrorHandler;
+
+import javax.mail.Authenticator;
+import javax.mail.BodyPart;
+import javax.mail.Message;
+import javax.mail.MessagingException;
+import javax.mail.Multipart;
+import javax.mail.PasswordAuthentication;
+import javax.mail.Session;
+import javax.mail.Transport;
+import javax.mail.internet.InternetAddress;
+import javax.mail.internet.MimeBodyPart;
+import javax.mail.internet.MimeMessage;
+import javax.mail.internet.MimeMultipart;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.util.Date;
+import java.util.Properties;
+
+/**
+ * Job error handler for sending error message by email.
+ */
+@Slf4j
+public final class EmailJobErrorHandler implements JobErrorHandler {
+    
+    public static final String CONFIG_PREFIX = "email";
+    
+    private EmailConfiguration emailConfiguration;
+    
+    private Session session;
+    
+    public EmailJobErrorHandler() {
+        loadConfiguration();
+    }
+    
+    @Override
+    public void handleException(final String jobName, final Throwable cause) {
+        try {
+            Preconditions.checkNotNull(emailConfiguration);
+            String content = buildContent(jobName, cause);
+            Message message = buildMessage(content);
+            sendMessage(message);
+        } catch (final NullPointerException | MessagingException ex) {
+            log.error("Elastic job: email job handler error", ex);
+        }

Review comment:
       if user don't set email configuration, `Preconditions.checkNotNull(emailConfiguration)` will throws NullPointerException,it menas user don't want email handler. So here will catch NullPointerException.




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [shardingsphere-elasticjob] vran-dev commented on a change in pull request #1474: Add EmailJobErrorHandler to support sending email when job error

Posted by GitBox <gi...@apache.org>.
vran-dev commented on a change in pull request #1474:
URL: https://github.com/apache/shardingsphere-elasticjob/pull/1474#discussion_r492151949



##########
File path: elasticjob-error-handler/elasticjob-error-handler-email/src/main/java/org/apache/shardingsphere/elasticjob/error/handler/email/EmailJobErrorHandler.java
##########
@@ -0,0 +1,126 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.elasticjob.error.handler.email;
+
+import com.google.common.base.Preconditions;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.shardingsphere.elasticjob.error.handler.JobErrorHandler;
+
+import javax.mail.Authenticator;
+import javax.mail.BodyPart;
+import javax.mail.Message;
+import javax.mail.MessagingException;
+import javax.mail.Multipart;
+import javax.mail.PasswordAuthentication;
+import javax.mail.Session;
+import javax.mail.Transport;
+import javax.mail.internet.InternetAddress;
+import javax.mail.internet.MimeBodyPart;
+import javax.mail.internet.MimeMessage;
+import javax.mail.internet.MimeMultipart;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.util.Date;
+import java.util.Properties;
+
+/**
+ * Job error handler for sending error message by email.
+ */
+@Slf4j
+public final class EmailJobErrorHandler implements JobErrorHandler {
+    
+    public static final String CONFIG_PREFIX = "email";
+    
+    private EmailConfiguration emailConfiguration;
+    
+    private Session session;
+    
+    public EmailJobErrorHandler() {
+        loadConfiguration();
+    }
+    
+    @Override
+    public void handleException(final String jobName, final Throwable cause) {
+        try {
+            Preconditions.checkNotNull(emailConfiguration);
+            String content = buildContent(jobName, cause);
+            Message message = buildMessage(content);
+            sendMessage(message);
+        } catch (final NullPointerException | MessagingException ex) {
+            log.error("Elastic job: email job handler error", ex);
+        }

Review comment:
       hello, I hava some suggestions you can refre to.
   
   if `emailConfiguration` is null means do nothing, i think use `check and  (log?) return`  is better than `check and catch`,  because
    1.  code taste: manually check and catch could increased code complexity
    2.  performance:  avoid use exception as control flow




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [shardingsphere-elasticjob] luky116 closed pull request #1474: Add EmailJobErrorHandler to support sending email when job error

Posted by GitBox <gi...@apache.org>.
luky116 closed pull request #1474:
URL: https://github.com/apache/shardingsphere-elasticjob/pull/1474


   


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [shardingsphere-elasticjob] TeslaCN commented on a change in pull request #1474: Add EmailJobErrorHandler to support sending email when job error

Posted by GitBox <gi...@apache.org>.
TeslaCN commented on a change in pull request #1474:
URL: https://github.com/apache/shardingsphere-elasticjob/pull/1474#discussion_r492165574



##########
File path: elasticjob-error-handler/elasticjob-error-handler-email/src/test/java/org/apache/shardingsphere/elasticjob/error/handler/email/EmailJobErrorHandlerTest.java
##########
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.elasticjob.error.handler.email;
+
+import lombok.SneakyThrows;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.ArgumentMatchers;
+import org.mockito.Mock;
+import org.mockito.junit.MockitoJUnitRunner;
+import org.slf4j.Logger;
+import java.lang.reflect.Field;
+import java.lang.reflect.Modifier;
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.junit.Assert.assertThat;
+import static org.mockito.Mockito.verify;
+
+@RunWith(MockitoJUnitRunner.class)
+public final class EmailJobErrorHandlerTest {
+        
+    @Mock
+    private Logger log;
+       
+    @Test
+    public void assertHandleExceptionFor() {
+        EmailJobErrorHandler emailJobErrorHandler = new EmailJobErrorHandler();
+        emailJobErrorHandler.handleException("test job name", new RuntimeException("test exception"));
+    }
+        
+    @Test
+    @SneakyThrows
+    public void assertHandleExceptionForNullConfiguration() {
+        EmailJobErrorHandler emailJobErrorHandler = new EmailJobErrorHandler();
+        Field emailConfigurationField = EmailJobErrorHandler.class.getDeclaredField("emailConfiguration");
+        emailConfigurationField.setAccessible(true);
+        emailConfigurationField.set(emailJobErrorHandler, null);
+        

Review comment:
       Remove redundant blank line.

##########
File path: elasticjob-error-handler/elasticjob-error-handler-email/src/test/resources/error-handler-email.yaml
##########
@@ -0,0 +1,26 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+email:
+  host: test.mail.com
+  port: 123
+  username: username
+  password: password
+  protocol: smtp
+  from: testmail@qiyi.com
+  to: xxx1@ejob.com
+  cc: xxx2@ejob.com

Review comment:
       Need a blank line.




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [shardingsphere-elasticjob] TeslaCN commented on a change in pull request #1474: Add EmailJobErrorHandler to support sending email when job error

Posted by GitBox <gi...@apache.org>.
TeslaCN commented on a change in pull request #1474:
URL: https://github.com/apache/shardingsphere-elasticjob/pull/1474#discussion_r491873382



##########
File path: elasticjob-error-handler/elasticjob-error-handler-email/src/main/java/org/apache/shardingsphere/elasticjob/error/handler/email/ConfigurationLoader.java
##########
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.elasticjob.error.handler.email;
+
+import lombok.NoArgsConstructor;
+import org.apache.shardingsphere.elasticjob.infra.yaml.YamlEngine;
+
+import java.io.InputStream;
+
+/**
+ * Job error configuration loader.
+ */
+@NoArgsConstructor

Review comment:
       "Private" access required.

##########
File path: elasticjob-error-handler/elasticjob-error-handler-email/pom.xml
##########
@@ -27,4 +27,38 @@
     </parent>
     
     <artifactId>elasticjob-error-handler-email</artifactId>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.shardingsphere.elasticjob</groupId>
+            <artifactId>elasticjob-error-handler-general</artifactId>
+            <version>${project.parent.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.projectlombok</groupId>
+            <artifactId>lombok</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>com.sun.mail</groupId>
+            <artifactId>javax.mail</artifactId>
+            <version>1.6.0</version>
+        </dependency>
+
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.mockito</groupId>
+            <artifactId>mockito-core</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.mockito</groupId>
+            <artifactId>mockito-inline</artifactId>
+        </dependency>

Review comment:
       "Test" scope is required.

##########
File path: elasticjob-error-handler/elasticjob-error-handler-general/src/main/java/org/apache/shardingsphere/elasticjob/error/handler/JobErrorHandlerFactory.java
##########
@@ -56,5 +56,5 @@ public static JobErrorHandler getHandler(final String type) {
             throw new JobConfigurationException("Can not find job error handler type '%s'.", type);
         }
         return HANDLERS.get(type);
-    } 
+    }

Review comment:
       Unnecessary changes.

##########
File path: elasticjob-error-handler/elasticjob-error-handler-general/src/test/java/org/apache/shardingsphere/elasticjob/error/handler/JobErrorHandlerFactoryTest.java
##########
@@ -7,7 +7,7 @@
  * the License.  You may obtain a copy of the License at
  *
  *     http://www.apache.org/licenses/LICENSE-2.0
- *  
+ *

Review comment:
       Unnecessary changes.

##########
File path: elasticjob-error-handler/elasticjob-error-handler-email/src/main/java/org/apache/shardingsphere/elasticjob/error/handler/email/EmailJobErrorHandler.java
##########
@@ -0,0 +1,126 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.elasticjob.error.handler.email;
+
+import com.google.common.base.Preconditions;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.shardingsphere.elasticjob.error.handler.JobErrorHandler;
+
+import javax.mail.Authenticator;
+import javax.mail.BodyPart;
+import javax.mail.Message;
+import javax.mail.MessagingException;
+import javax.mail.Multipart;
+import javax.mail.PasswordAuthentication;
+import javax.mail.Session;
+import javax.mail.Transport;
+import javax.mail.internet.InternetAddress;
+import javax.mail.internet.MimeBodyPart;
+import javax.mail.internet.MimeMessage;
+import javax.mail.internet.MimeMultipart;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.util.Date;
+import java.util.Properties;
+
+/**
+ * Job error handler for sending error message by email.
+ */
+@Slf4j
+public final class EmailJobErrorHandler implements JobErrorHandler {
+    
+    public static final String CONFIG_PREFIX = "email";
+    
+    private EmailConfiguration emailConfiguration;
+    
+    private Session session;
+    
+    public EmailJobErrorHandler() {
+        loadConfiguration();
+    }
+    
+    @Override
+    public void handleException(final String jobName, final Throwable cause) {
+        try {
+            Preconditions.checkNotNull(emailConfiguration);
+            String content = buildContent(jobName, cause);
+            Message message = buildMessage(content);
+            sendMessage(message);
+        } catch (final NullPointerException | MessagingException ex) {
+            log.error("Elastic job: email job handler error", ex);
+        }

Review comment:
       Catch 'NullPointerException' seems weird.

##########
File path: elasticjob-error-handler/elasticjob-error-handler-general/src/test/java/org/apache/shardingsphere/elasticjob/error/handler/impl/IgnoreJobErrorHandlerTest.java
##########
@@ -20,7 +20,7 @@
 import org.junit.Test;
 
 public final class IgnoreJobErrorHandlerTest {
-    
+

Review comment:
       Unnecessary changes.

##########
File path: elasticjob-error-handler/elasticjob-error-handler-email/src/main/resources/META-INF/services/org.apache.shardingsphere.elasticjob.error.handler.JobErrorHandler
##########
@@ -15,6 +15,4 @@
 # limitations under the License.
 #
 
-org.apache.shardingsphere.elasticjob.infra.handler.error.impl.LogJobErrorHandler
-org.apache.shardingsphere.elasticjob.infra.handler.error.impl.IgnoreJobErrorHandler
-org.apache.shardingsphere.elasticjob.infra.handler.error.impl.ThrowJobErrorHandler
+org.apache.shardingsphere.elasticjob.error.handler.email.EmailJobErrorHandler

Review comment:
       Need a blank line.

##########
File path: elasticjob-error-handler/elasticjob-error-handler-general/src/test/java/org/apache/shardingsphere/elasticjob/error/handler/impl/IgnoreJobErrorHandlerTest.java
##########
@@ -7,7 +7,7 @@
  * the License.  You may obtain a copy of the License at
  *
  *     http://www.apache.org/licenses/LICENSE-2.0
- *  
+ *

Review comment:
       Unnecessary changes.

##########
File path: elasticjob-error-handler/elasticjob-error-handler-email/src/test/java/org/apache/shardingsphere/elasticjob/error/handler/email/EmailJobErrorHandlerTest.java
##########
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.elasticjob.error.handler.email;
+
+import lombok.SneakyThrows;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.ArgumentMatchers;
+import org.mockito.Mock;
+import org.mockito.junit.MockitoJUnitRunner;
+import org.slf4j.Logger;
+import java.lang.reflect.Field;
+import java.lang.reflect.Modifier;
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.junit.Assert.assertThat;
+import static org.mockito.Mockito.verify;
+
+@RunWith(MockitoJUnitRunner.class)
+public final class EmailJobErrorHandlerTest {
+        
+    @Mock
+    private Logger log;
+       
+    @Test
+    public void assertHandleExceptionFor() {
+        EmailJobErrorHandler emailJobErrorHandler = new EmailJobErrorHandler();
+        emailJobErrorHandler.handleException("test job name", new RuntimeException("test exception"));
+    }
+        
+    @Test
+    @SneakyThrows
+    public void assertHandleExceptionForNullConfiguration() {
+        EmailJobErrorHandler emailJobErrorHandler = new EmailJobErrorHandler();
+        Field emailConfigurationField = EmailJobErrorHandler.class.getDeclaredField("emailConfiguration");
+        emailConfigurationField.setAccessible(true);
+        emailConfigurationField.set(emailJobErrorHandler, null);
+        

Review comment:
       Remove redundant blank line.

##########
File path: elasticjob-error-handler/elasticjob-error-handler-email/src/test/resources/error-handler-email.yaml
##########
@@ -0,0 +1,26 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+email:
+  host: test.mail.com
+  port: 123
+  username: username
+  password: password
+  protocol: smtp
+  from: testmail@qiyi.com
+  to: xxx1@ejob.com
+  cc: xxx2@ejob.com

Review comment:
       Need a blank line.




----------------------------------------------------------------
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:
users@infra.apache.org