You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dolphinscheduler.apache.org by GitBox <gi...@apache.org> on 2020/09/16 04:51:13 UTC

[GitHub] [incubator-dolphinscheduler] Technoboy- commented on a change in pull request #3746: [fix-3745][server] server get tasktype NPE exception

Technoboy- commented on a change in pull request #3746:
URL: https://github.com/apache/incubator-dolphinscheduler/pull/3746#discussion_r489159845



##########
File path: dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/TaskParametersUtils.java
##########
@@ -55,41 +55,42 @@ private TaskParametersUtils() {
      * @return task parameters
      */
     public static AbstractParameters getParameters(String taskType, String parameter) {
-        try {
-            switch (EnumUtils.getEnum(TaskType.class, taskType)) {
-                case SUB_PROCESS:
-                    return JSONUtils.parseObject(parameter, SubProcessParameters.class);
-                case SHELL:
-                case WATERDROP:
-                    return JSONUtils.parseObject(parameter, ShellParameters.class);
-                case PROCEDURE:
-                    return JSONUtils.parseObject(parameter, ProcedureParameters.class);
-                case SQL:
-                    return JSONUtils.parseObject(parameter, SqlParameters.class);
-                case MR:
-                    return JSONUtils.parseObject(parameter, MapreduceParameters.class);
-                case SPARK:
-                    return JSONUtils.parseObject(parameter, SparkParameters.class);
-                case PYTHON:
-                    return JSONUtils.parseObject(parameter, PythonParameters.class);
-                case DEPENDENT:
-                    return JSONUtils.parseObject(parameter, DependentParameters.class);
-                case FLINK:
-                    return JSONUtils.parseObject(parameter, FlinkParameters.class);
-                case HTTP:
-                    return JSONUtils.parseObject(parameter, HttpParameters.class);
-                case DATAX:
-                    return JSONUtils.parseObject(parameter, DataxParameters.class);
-                case CONDITIONS:
-                    return JSONUtils.parseObject(parameter, ConditionsParameters.class);
-                case SQOOP:
-                    return JSONUtils.parseObject(parameter, SqoopParameters.class);
-                default:
-                    return null;
-            }
-        } catch (Exception e) {
-            logger.error(e.getMessage(), e);
+        TaskType anEnum = EnumUtils.getEnum(TaskType.class, taskType);
+        if (anEnum == null) {
+            logger.error("not support task type: {}", taskType);
+            return null;

Review comment:
       Why not throw InvalidArgumentException?




----------------------------------------------------------------
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