This is an automated email from the ASF dual-hosted git repository.

zhangliang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere-elasticjob.git


The following commit(s) were added to refs/heads/master by this push:
     new a2fa5d2  Use JobPropertiesValidator to validate error handler (#1645)
a2fa5d2 is described below

commit a2fa5d257878651bb90ef6a57477d9dda3c4e7fa
Author: Liang Zhang <[email protected]>
AuthorDate: Fri Oct 23 14:29:16 2020 +0800

    Use JobPropertiesValidator to validate error handler (#1645)
    
    * Add JobPropertiesValidator
    
    * Add DingtalkJobErrorHandlerPropertiesValidator
    
    * Add JobPropertiesValidateRule
    
    * Add WechatJobErrorHandlerPropertiesValidator
    
    * Add EmailJobErrorHandlerPropertiesValidator
---
 .../JobErrorHandlerPropertiesValidator.java        | 26 ++++++++++
 ...DingtalkJobErrorHandlerPropertiesValidator.java | 41 +++++++++++++++
 ...rror.handler.JobErrorHandlerPropertiesValidator | 18 +++++++
 .../EmailJobErrorHandlerPropertiesValidator.java   | 45 ++++++++++++++++
 ...rror.handler.JobErrorHandlerPropertiesValidator | 18 +++++++
 .../WechatJobErrorHandlerPropertiesValidator.java  | 41 +++++++++++++++
 ...rror.handler.JobErrorHandlerPropertiesValidator | 18 +++++++
 .../infra/validator/JobPropertiesValidateRule.java | 60 ++++++++++++++++++++++
 .../infra/validator/JobPropertiesValidator.java    | 35 +++++++++++++
 .../lite/internal/schedule/JobScheduler.java       | 17 ++++++
 10 files changed, 319 insertions(+)

diff --git 
a/elasticjob-error-handler/elasticjob-error-handler-spi/src/main/java/org/apache/shardingsphere/elasticjob/error/handler/JobErrorHandlerPropertiesValidator.java
 
b/elasticjob-error-handler/elasticjob-error-handler-spi/src/main/java/org/apache/shardingsphere/elasticjob/error/handler/JobErrorHandlerPropertiesValidator.java
new file mode 100644
index 0000000..bcc26b2
--- /dev/null
+++ 
b/elasticjob-error-handler/elasticjob-error-handler-spi/src/main/java/org/apache/shardingsphere/elasticjob/error/handler/JobErrorHandlerPropertiesValidator.java
@@ -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.
+ */
+
+package org.apache.shardingsphere.elasticjob.error.handler;
+
+import 
org.apache.shardingsphere.elasticjob.infra.validator.JobPropertiesValidator;
+
+/**
+ * Job error handler properties validator.
+ */
+public interface JobErrorHandlerPropertiesValidator extends 
JobPropertiesValidator {
+}
diff --git 
a/elasticjob-error-handler/elasticjob-error-handler-type/elasticjob-error-handler-dingtalk/src/main/java/org/apache/shardingsphere/elasticjob/error/handler/dingtalk/DingtalkJobErrorHandlerPropertiesValidator.java
 
b/elasticjob-error-handler/elasticjob-error-handler-type/elasticjob-error-handler-dingtalk/src/main/java/org/apache/shardingsphere/elasticjob/error/handler/dingtalk/DingtalkJobErrorHandlerPropertiesValidator.java
new file mode 100644
index 0000000..fa170da
--- /dev/null
+++ 
b/elasticjob-error-handler/elasticjob-error-handler-type/elasticjob-error-handler-dingtalk/src/main/java/org/apache/shardingsphere/elasticjob/error/handler/dingtalk/DingtalkJobErrorHandlerPropertiesValidator.java
@@ -0,0 +1,41 @@
+/*
+ * 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.dingtalk;
+
+import 
org.apache.shardingsphere.elasticjob.error.handler.JobErrorHandlerPropertiesValidator;
+import 
org.apache.shardingsphere.elasticjob.infra.validator.JobPropertiesValidateRule;
+
+import java.util.Properties;
+
+/**
+ * Job error handler properties validator for dingtalk.
+ */
+public final class DingtalkJobErrorHandlerPropertiesValidator implements 
JobErrorHandlerPropertiesValidator {
+    
+    @Override
+    public void validate(final Properties props) {
+        JobPropertiesValidateRule.validateIsRequired(props, 
DingtalkPropertiesConstants.WEBHOOK);
+        JobPropertiesValidateRule.validateIsPositiveInteger(props, 
DingtalkPropertiesConstants.CONNECT_TIMEOUT_MILLISECONDS);
+        JobPropertiesValidateRule.validateIsPositiveInteger(props, 
DingtalkPropertiesConstants.READ_TIMEOUT_MILLISECONDS);
+    }
+    
+    @Override
+    public String getType() {
+        return "DINGTALK";
+    }
+}
diff --git 
a/elasticjob-error-handler/elasticjob-error-handler-type/elasticjob-error-handler-dingtalk/src/main/resources/META-INF/services/org.apache.shardingsphere.elasticjob.error.handler.JobErrorHandlerPropertiesValidator
 
b/elasticjob-error-handler/elasticjob-error-handler-type/elasticjob-error-handler-dingtalk/src/main/resources/META-INF/services/org.apache.shardingsphere.elasticjob.error.handler.JobErrorHandlerPropertiesValidator
new file mode 100644
index 0000000..84aaa88
--- /dev/null
+++ 
b/elasticjob-error-handler/elasticjob-error-handler-type/elasticjob-error-handler-dingtalk/src/main/resources/META-INF/services/org.apache.shardingsphere.elasticjob.error.handler.JobErrorHandlerPropertiesValidator
@@ -0,0 +1,18 @@
+#
+# 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.
+#
+
+org.apache.shardingsphere.elasticjob.error.handler.dingtalk.DingtalkJobErrorHandlerPropertiesValidator
diff --git 
a/elasticjob-error-handler/elasticjob-error-handler-type/elasticjob-error-handler-email/src/main/java/org/apache/shardingsphere/elasticjob/error/handler/email/EmailJobErrorHandlerPropertiesValidator.java
 
b/elasticjob-error-handler/elasticjob-error-handler-type/elasticjob-error-handler-email/src/main/java/org/apache/shardingsphere/elasticjob/error/handler/email/EmailJobErrorHandlerPropertiesValidator.java
new file mode 100644
index 0000000..c16eb2c
--- /dev/null
+++ 
b/elasticjob-error-handler/elasticjob-error-handler-type/elasticjob-error-handler-email/src/main/java/org/apache/shardingsphere/elasticjob/error/handler/email/EmailJobErrorHandlerPropertiesValidator.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 
org.apache.shardingsphere.elasticjob.error.handler.JobErrorHandlerPropertiesValidator;
+import 
org.apache.shardingsphere.elasticjob.infra.validator.JobPropertiesValidateRule;
+
+import java.util.Properties;
+
+/**
+ * Job error handler properties validator for email.
+ */
+public final class EmailJobErrorHandlerPropertiesValidator implements 
JobErrorHandlerPropertiesValidator {
+    
+    @Override
+    public void validate(final Properties props) {
+        JobPropertiesValidateRule.validateIsRequired(props, 
EmailPropertiesConstants.HOST);
+        JobPropertiesValidateRule.validateIsRequired(props, 
EmailPropertiesConstants.PORT);
+        JobPropertiesValidateRule.validateIsPositiveInteger(props, 
EmailPropertiesConstants.PORT);
+        JobPropertiesValidateRule.validateIsRequired(props, 
EmailPropertiesConstants.USERNAME);
+        JobPropertiesValidateRule.validateIsRequired(props, 
EmailPropertiesConstants.PASSWORD);
+        JobPropertiesValidateRule.validateIsRequired(props, 
EmailPropertiesConstants.FROM);
+        JobPropertiesValidateRule.validateIsRequired(props, 
EmailPropertiesConstants.TO);
+    }
+    
+    @Override
+    public String getType() {
+        return "EMAIL";
+    }
+}
diff --git 
a/elasticjob-error-handler/elasticjob-error-handler-type/elasticjob-error-handler-email/src/main/resources/META-INF/services/org.apache.shardingsphere.elasticjob.error.handler.JobErrorHandlerPropertiesValidator
 
b/elasticjob-error-handler/elasticjob-error-handler-type/elasticjob-error-handler-email/src/main/resources/META-INF/services/org.apache.shardingsphere.elasticjob.error.handler.JobErrorHandlerPropertiesValidator
new file mode 100644
index 0000000..c1b3896
--- /dev/null
+++ 
b/elasticjob-error-handler/elasticjob-error-handler-type/elasticjob-error-handler-email/src/main/resources/META-INF/services/org.apache.shardingsphere.elasticjob.error.handler.JobErrorHandlerPropertiesValidator
@@ -0,0 +1,18 @@
+#
+# 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.
+#
+
+org.apache.shardingsphere.elasticjob.error.handler.email.EmailJobErrorHandlerPropertiesValidator
diff --git 
a/elasticjob-error-handler/elasticjob-error-handler-type/elasticjob-error-handler-wechat/src/main/java/org/apache/shardingsphere/elasticjob/error/handler/wechat/WechatJobErrorHandlerPropertiesValidator.java
 
b/elasticjob-error-handler/elasticjob-error-handler-type/elasticjob-error-handler-wechat/src/main/java/org/apache/shardingsphere/elasticjob/error/handler/wechat/WechatJobErrorHandlerPropertiesValidator.java
new file mode 100644
index 0000000..b885f98
--- /dev/null
+++ 
b/elasticjob-error-handler/elasticjob-error-handler-type/elasticjob-error-handler-wechat/src/main/java/org/apache/shardingsphere/elasticjob/error/handler/wechat/WechatJobErrorHandlerPropertiesValidator.java
@@ -0,0 +1,41 @@
+/*
+ * 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.wechat;
+
+import 
org.apache.shardingsphere.elasticjob.error.handler.JobErrorHandlerPropertiesValidator;
+import 
org.apache.shardingsphere.elasticjob.infra.validator.JobPropertiesValidateRule;
+
+import java.util.Properties;
+
+/**
+ * Job error handler properties validator for wechat.
+ */
+public final class WechatJobErrorHandlerPropertiesValidator implements 
JobErrorHandlerPropertiesValidator {
+    
+    @Override
+    public void validate(final Properties props) {
+        JobPropertiesValidateRule.validateIsRequired(props, 
WechatPropertiesConstants.WEBHOOK);
+        JobPropertiesValidateRule.validateIsPositiveInteger(props, 
WechatPropertiesConstants.CONNECT_TIMEOUT_MILLISECONDS);
+        JobPropertiesValidateRule.validateIsPositiveInteger(props, 
WechatPropertiesConstants.READ_TIMEOUT_MILLISECONDS);
+    }
+    
+    @Override
+    public String getType() {
+        return "WECHAT";
+    }
+}
diff --git 
a/elasticjob-error-handler/elasticjob-error-handler-type/elasticjob-error-handler-wechat/src/main/resources/META-INF/services/org.apache.shardingsphere.elasticjob.error.handler.JobErrorHandlerPropertiesValidator
 
b/elasticjob-error-handler/elasticjob-error-handler-type/elasticjob-error-handler-wechat/src/main/resources/META-INF/services/org.apache.shardingsphere.elasticjob.error.handler.JobErrorHandlerPropertiesValidator
new file mode 100644
index 0000000..9ae1973
--- /dev/null
+++ 
b/elasticjob-error-handler/elasticjob-error-handler-type/elasticjob-error-handler-wechat/src/main/resources/META-INF/services/org.apache.shardingsphere.elasticjob.error.handler.JobErrorHandlerPropertiesValidator
@@ -0,0 +1,18 @@
+#
+# 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.
+#
+
+org.apache.shardingsphere.elasticjob.error.handler.wechat.WechatJobErrorHandlerPropertiesValidator
diff --git 
a/elasticjob-infra/elasticjob-infra-common/src/main/java/org/apache/shardingsphere/elasticjob/infra/validator/JobPropertiesValidateRule.java
 
b/elasticjob-infra/elasticjob-infra-common/src/main/java/org/apache/shardingsphere/elasticjob/infra/validator/JobPropertiesValidateRule.java
new file mode 100644
index 0000000..6c384a4
--- /dev/null
+++ 
b/elasticjob-infra/elasticjob-infra-common/src/main/java/org/apache/shardingsphere/elasticjob/infra/validator/JobPropertiesValidateRule.java
@@ -0,0 +1,60 @@
+/*
+ * 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.infra.validator;
+
+import com.google.common.base.Preconditions;
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
+
+import java.util.Properties;
+
+/**
+ * Job properties validate rule.
+ */
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
+public final class JobPropertiesValidateRule {
+    
+    /**
+     * Validate property value is required.
+     * 
+     * @param props properties to be validated
+     * @param key property key to be validated
+     */
+    public static void validateIsRequired(final Properties props, final String 
key) {
+        Preconditions.checkNotNull(props.getProperty(key), "The property `%s` 
is required.", key);
+    }
+    
+    /**
+     * Validate property value is positive integer.
+     * 
+     * @param props properties to be validated
+     * @param key property key to be validated
+     */
+    public static void validateIsPositiveInteger(final Properties props, final 
String key) {
+        String propertyValue = props.getProperty(key);
+        if (null != propertyValue) {
+            int integerValue;
+            try {
+                integerValue = Integer.parseInt(propertyValue);
+            } catch (final NumberFormatException ignored) {
+                throw new IllegalArgumentException(String.format("The property 
`%s` should be integer.", key));
+            }
+            Preconditions.checkArgument(integerValue > 0, "The property `%s` 
should be positive.", key);
+        }
+    }
+}
diff --git 
a/elasticjob-infra/elasticjob-infra-common/src/main/java/org/apache/shardingsphere/elasticjob/infra/validator/JobPropertiesValidator.java
 
b/elasticjob-infra/elasticjob-infra-common/src/main/java/org/apache/shardingsphere/elasticjob/infra/validator/JobPropertiesValidator.java
new file mode 100644
index 0000000..f3cbfd1
--- /dev/null
+++ 
b/elasticjob-infra/elasticjob-infra-common/src/main/java/org/apache/shardingsphere/elasticjob/infra/validator/JobPropertiesValidator.java
@@ -0,0 +1,35 @@
+/*
+ * 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.infra.validator;
+
+import org.apache.shardingsphere.elasticjob.infra.spi.TypedSPI;
+
+import java.util.Properties;
+
+/**
+ * Job properties validator.
+ */
+public interface JobPropertiesValidator extends TypedSPI {
+    
+    /**
+     * Validate job properties.
+     * 
+     * @param props job properties
+     */
+    void validate(Properties props);
+}
diff --git 
a/elasticjob-lite/elasticjob-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/internal/schedule/JobScheduler.java
 
b/elasticjob-lite/elasticjob-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/internal/schedule/JobScheduler.java
index 0a344ff..7385fb5 100644
--- 
a/elasticjob-lite/elasticjob-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/internal/schedule/JobScheduler.java
+++ 
b/elasticjob-lite/elasticjob-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/internal/schedule/JobScheduler.java
@@ -20,11 +20,13 @@ package 
org.apache.shardingsphere.elasticjob.lite.internal.schedule;
 import lombok.Getter;
 import org.apache.shardingsphere.elasticjob.api.ElasticJob;
 import org.apache.shardingsphere.elasticjob.api.JobConfiguration;
+import 
org.apache.shardingsphere.elasticjob.error.handler.JobErrorHandlerPropertiesValidator;
 import org.apache.shardingsphere.elasticjob.executor.ElasticJobExecutor;
 import org.apache.shardingsphere.elasticjob.infra.exception.JobSystemException;
 import org.apache.shardingsphere.elasticjob.infra.handler.sharding.JobInstance;
 import org.apache.shardingsphere.elasticjob.infra.listener.ElasticJobListener;
 import 
org.apache.shardingsphere.elasticjob.infra.listener.ElasticJobListenerFactory;
+import org.apache.shardingsphere.elasticjob.infra.spi.ElasticJobServiceLoader;
 import 
org.apache.shardingsphere.elasticjob.lite.api.listener.AbstractDistributeOnceElasticJobListener;
 import 
org.apache.shardingsphere.elasticjob.lite.internal.guarantee.GuaranteeService;
 import 
org.apache.shardingsphere.elasticjob.lite.internal.setup.JobClassNameProviderFactory;
@@ -48,6 +50,10 @@ import java.util.stream.Collectors;
  */
 public final class JobScheduler {
     
+    static {
+        
ElasticJobServiceLoader.registerTypedService(JobErrorHandlerPropertiesValidator.class);
+    }
+    
     private static final String JOB_EXECUTOR_DATA_MAP_KEY = "jobExecutor";
     
     @Getter
@@ -79,6 +85,7 @@ public final class JobScheduler {
         jobExecutor = null == elasticJob ? new 
ElasticJobExecutor(elasticJobType, jobConfig, jobFacade) : new 
ElasticJobExecutor(elasticJob, jobConfig, jobFacade);
         String jobClassName = 
JobClassNameProviderFactory.getProvider().getJobClassName(elasticJob);
         this.jobConfig = setUpFacade.setUpJobConfiguration(jobClassName, 
jobConfig);
+        validateJobProperties();
         setGuaranteeServiceForElasticJobListeners(regCenter, jobListeners);
         jobScheduleController = createJobScheduleController();
     }
@@ -92,6 +99,7 @@ public final class JobScheduler {
         jobFacade = new LiteJobFacade(regCenter, jobConfig.getJobName(), 
jobListeners, findTracingConfiguration(jobConfig).orElse(null));
         jobExecutor = new ElasticJobExecutor(elasticJobType, jobConfig, 
jobFacade);
         this.jobConfig = setUpFacade.setUpJobConfiguration(elasticJobType, 
jobConfig);
+        validateJobProperties();
         setGuaranteeServiceForElasticJobListeners(regCenter, jobListeners);
         jobScheduleController = createJobScheduleController();
     }
@@ -106,6 +114,15 @@ public final class JobScheduler {
         return jobConfig.getExtraConfigurations().stream().filter(each -> each 
instanceof TracingConfiguration).findFirst().map(extraConfig -> 
(TracingConfiguration<?>) extraConfig);
     }
     
+    private void validateJobProperties() {
+        validateJobErrorHandlerProperties();
+    }
+    
+    private void validateJobErrorHandlerProperties() {
+        
ElasticJobServiceLoader.newTypedServiceInstance(JobErrorHandlerPropertiesValidator.class,
 jobConfig.getJobErrorHandlerType(), jobConfig.getProps())
+                .ifPresent(validator -> 
validator.validate(jobConfig.getProps()));
+    }
+    
     private void setGuaranteeServiceForElasticJobListeners(final 
CoordinatorRegistryCenter regCenter, final Collection<ElasticJobListener> 
elasticJobListeners) {
         GuaranteeService guaranteeService = new GuaranteeService(regCenter, 
jobConfig.getJobName());
         for (ElasticJobListener each : elasticJobListeners) {

Reply via email to