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

zihaoxiang pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/dolphinscheduler.git


The following commit(s) were added to refs/heads/dev by this push:
     new ce7440d5b7 [Improvement-17288] CodeGenerateException is swallowed in 
ProcessDefinitionDemo (#17289)
ce7440d5b7 is described below

commit ce7440d5b7468bcd3d32c10176714c706bac6365
Author: Wenjun Ruan <[email protected]>
AuthorDate: Sat Jun 28 17:33:49 2025 +0800

    [Improvement-17288] CodeGenerateException is swallowed in 
ProcessDefinitionDemo (#17289)
---
 .../dolphinscheduler/api/python/PythonGateway.java |   2 +-
 .../api/service/impl/EnvironmentServiceImpl.java   |  12 +--
 .../api/service/impl/K8SNamespaceServiceImpl.java  |  13 +--
 .../service/impl/ProjectParameterServiceImpl.java  |  30 +++---
 .../api/service/impl/ProjectServiceImpl.java       |  27 ++---
 .../service/impl/TaskDefinitionServiceImpl.java    |  12 +--
 .../impl/WorkflowDefinitionServiceImpl.java        |  57 +++--------
 .../api/python/PythonGatewayTest.java              |   3 +-
 .../api/service/ProjectParameterServiceTest.java   |   7 +-
 .../api/service/impl/EnvironmentServiceTest.java   |   3 +-
 .../service/process/ProcessService.java            |   3 +-
 .../service/process/ProcessServiceImpl.java        |   3 +-
 ...ateProcessDemo.java => CreateWorkflowDemo.java} |  14 +--
 ...java => ProxyWorkflowDefinitionController.java} |   2 +-
 ...nitionDemo.java => WorkflowDefinitionDemo.java} | 111 +++++++++------------
 15 files changed, 104 insertions(+), 195 deletions(-)

diff --git 
a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/python/PythonGateway.java
 
b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/python/PythonGateway.java
index b3d3298540..d6650a4044 100644
--- 
a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/python/PythonGateway.java
+++ 
b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/python/PythonGateway.java
@@ -179,7 +179,7 @@ public class PythonGateway {
     }
 
     public Map<String, Long> getCodeAndVersion(String projectName, String 
workflowDefinitionName,
-                                               String taskName) throws 
CodeGenerateUtils.CodeGenerateException {
+                                               String taskName) {
         Project project = projectMapper.queryByName(projectName);
         Map<String, Long> result = new HashMap<>();
         // project do not exists, mean task not exists too, so we should 
directly return init value
diff --git 
a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/EnvironmentServiceImpl.java
 
b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/EnvironmentServiceImpl.java
index b604fd7c1a..591ab3ecaf 100644
--- 
a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/EnvironmentServiceImpl.java
+++ 
b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/EnvironmentServiceImpl.java
@@ -31,7 +31,6 @@ import org.apache.dolphinscheduler.common.constants.Constants;
 import org.apache.dolphinscheduler.common.enums.AuthorizationType;
 import org.apache.dolphinscheduler.common.enums.UserType;
 import org.apache.dolphinscheduler.common.utils.CodeGenerateUtils;
-import 
org.apache.dolphinscheduler.common.utils.CodeGenerateUtils.CodeGenerateException;
 import org.apache.dolphinscheduler.common.utils.JSONUtils;
 import org.apache.dolphinscheduler.dao.entity.Environment;
 import org.apache.dolphinscheduler.dao.entity.EnvironmentWorkerGroupRelation;
@@ -121,16 +120,7 @@ public class EnvironmentServiceImpl extends 
BaseServiceImpl implements Environme
         env.setOperator(loginUser.getId());
         env.setCreateTime(new Date());
         env.setUpdateTime(new Date());
-        long code = 0L;
-        try {
-            code = CodeGenerateUtils.genCode();
-            env.setCode(code);
-        } catch (CodeGenerateException e) {
-            log.error("Generate environment code error.", e);
-        }
-        if (code == 0L) {
-            throw new ServiceException(Status.INTERNAL_SERVER_ERROR_ARGS, 
"Error generating environment code");
-        }
+        env.setCode(CodeGenerateUtils.genCode());
 
         if (environmentMapper.insert(env) > 0) {
             if (!StringUtils.isEmpty(workerGroups)) {
diff --git 
a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/K8SNamespaceServiceImpl.java
 
b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/K8SNamespaceServiceImpl.java
index 7543616f31..9f3309414c 100644
--- 
a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/K8SNamespaceServiceImpl.java
+++ 
b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/K8SNamespaceServiceImpl.java
@@ -139,17 +139,8 @@ public class K8SNamespaceServiceImpl extends 
BaseServiceImpl implements K8sNames
             return result;
         }
 
-        long code = 0L;
-        try {
-            code = CodeGenerateUtils.genCode();
-            cluster.setCode(code);
-        } catch (CodeGenerateUtils.CodeGenerateException e) {
-            log.error("Generate cluster code error.", e);
-        }
-        if (code == 0L) {
-            putMsg(result, Status.INTERNAL_SERVER_ERROR_ARGS, "Error 
generating cluster code");
-            return result;
-        }
+        long code = CodeGenerateUtils.genCode();
+        cluster.setCode(code);
 
         K8sNamespace k8sNamespaceObj = new K8sNamespace();
         Date now = new Date();
diff --git 
a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProjectParameterServiceImpl.java
 
b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProjectParameterServiceImpl.java
index f0e157eaa3..0c6b4309b6 100644
--- 
a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProjectParameterServiceImpl.java
+++ 
b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProjectParameterServiceImpl.java
@@ -92,24 +92,18 @@ public class ProjectParameterServiceImpl extends 
BaseServiceImpl implements Proj
 
         Date now = new Date();
 
-        try {
-            projectParameter = ProjectParameter
-                    .builder()
-                    .paramName(projectParameterName)
-                    .paramValue(projectParameterValue)
-                    .paramDataType(projectParameterDataType)
-                    .code(CodeGenerateUtils.genCode())
-                    .projectCode(projectCode)
-                    .userId(loginUser.getId())
-                    .operator(loginUser.getId())
-                    .createTime(now)
-                    .updateTime(now)
-                    .build();
-        } catch (CodeGenerateUtils.CodeGenerateException e) {
-            log.error("Generate project parameter code error.", e);
-            putMsg(result, Status.CREATE_PROJECT_PARAMETER_ERROR);
-            return result;
-        }
+        projectParameter = ProjectParameter
+                .builder()
+                .paramName(projectParameterName)
+                .paramValue(projectParameterValue)
+                .paramDataType(projectParameterDataType)
+                .code(CodeGenerateUtils.genCode())
+                .projectCode(projectCode)
+                .userId(loginUser.getId())
+                .operator(loginUser.getId())
+                .createTime(now)
+                .updateTime(now)
+                .build();
 
         if (projectParameterMapper.insert(projectParameter) > 0) {
             log.info("Project parameter is created and id is :{}", 
projectParameter.getId());
diff --git 
a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProjectServiceImpl.java
 
b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProjectServiceImpl.java
index ef36d95145..49d4d0633a 100644
--- 
a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProjectServiceImpl.java
+++ 
b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProjectServiceImpl.java
@@ -31,7 +31,6 @@ import org.apache.dolphinscheduler.common.constants.Constants;
 import org.apache.dolphinscheduler.common.enums.AuthorizationType;
 import org.apache.dolphinscheduler.common.enums.UserType;
 import org.apache.dolphinscheduler.common.utils.CodeGenerateUtils;
-import 
org.apache.dolphinscheduler.common.utils.CodeGenerateUtils.CodeGenerateException;
 import org.apache.dolphinscheduler.dao.entity.Project;
 import org.apache.dolphinscheduler.dao.entity.ProjectUser;
 import org.apache.dolphinscheduler.dao.entity.ProjectWorkflowDefinitionCount;
@@ -120,22 +119,16 @@ public class ProjectServiceImpl extends BaseServiceImpl 
implements ProjectServic
 
         Date now = new Date();
 
-        try {
-            project = Project
-                    .builder()
-                    .name(name)
-                    .code(CodeGenerateUtils.genCode())
-                    .description(desc)
-                    .userId(loginUser.getId())
-                    .userName(loginUser.getUserName())
-                    .createTime(now)
-                    .updateTime(now)
-                    .build();
-        } catch (CodeGenerateException e) {
-            log.error("Generate workflow definition code error.", e);
-            putMsg(result, Status.CREATE_PROJECT_ERROR);
-            return result;
-        }
+        project = Project
+                .builder()
+                .name(name)
+                .code(CodeGenerateUtils.genCode())
+                .description(desc)
+                .userId(loginUser.getId())
+                .userName(loginUser.getUserName())
+                .createTime(now)
+                .updateTime(now)
+                .build();
 
         if (projectMapper.insert(project) > 0) {
             log.info("Project is created and id is :{}", project.getId());
diff --git 
a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskDefinitionServiceImpl.java
 
b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskDefinitionServiceImpl.java
index 5f7ccfcf76..0dfa0ce719 100644
--- 
a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskDefinitionServiceImpl.java
+++ 
b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskDefinitionServiceImpl.java
@@ -45,7 +45,6 @@ import org.apache.dolphinscheduler.common.enums.ReleaseState;
 import org.apache.dolphinscheduler.common.enums.TaskExecuteType;
 import org.apache.dolphinscheduler.common.enums.TimeoutFlag;
 import org.apache.dolphinscheduler.common.utils.CodeGenerateUtils;
-import 
org.apache.dolphinscheduler.common.utils.CodeGenerateUtils.CodeGenerateException;
 import org.apache.dolphinscheduler.common.utils.JSONUtils;
 import org.apache.dolphinscheduler.dao.entity.Project;
 import org.apache.dolphinscheduler.dao.entity.TaskDefinition;
@@ -862,14 +861,11 @@ public class TaskDefinitionServiceImpl extends 
BaseServiceImpl implements TaskDe
             return result;
         }
         List<Long> taskCodes = new ArrayList<>();
-        try {
-            for (int i = 0; i < genNum; i++) {
-                taskCodes.add(CodeGenerateUtils.genCode());
-            }
-        } catch (CodeGenerateException e) {
-            log.error("Generate task definition code error.", e);
-            putMsg(result, Status.INTERNAL_SERVER_ERROR_ARGS, "Error 
generating task definition code");
+
+        for (int i = 0; i < genNum; i++) {
+            taskCodes.add(CodeGenerateUtils.genCode());
         }
+
         putMsg(result, Status.SUCCESS);
         // return workflowDefinitionCode
         result.put(Constants.DATA_LIST, taskCodes);
diff --git 
a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/WorkflowDefinitionServiceImpl.java
 
b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/WorkflowDefinitionServiceImpl.java
index af95d6c06f..3a72c7b116 100644
--- 
a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/WorkflowDefinitionServiceImpl.java
+++ 
b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/WorkflowDefinitionServiceImpl.java
@@ -75,7 +75,6 @@ import org.apache.dolphinscheduler.common.graph.DAG;
 import org.apache.dolphinscheduler.common.lifecycle.ServerLifeCycleManager;
 import org.apache.dolphinscheduler.common.model.TaskNodeRelation;
 import org.apache.dolphinscheduler.common.utils.CodeGenerateUtils;
-import 
org.apache.dolphinscheduler.common.utils.CodeGenerateUtils.CodeGenerateException;
 import org.apache.dolphinscheduler.common.utils.DateUtils;
 import org.apache.dolphinscheduler.common.utils.JSONUtils;
 import org.apache.dolphinscheduler.dao.entity.DagData;
@@ -349,14 +348,7 @@ public class WorkflowDefinitionServiceImpl extends 
BaseServiceImpl implements Wo
         WorkflowDefinition workflowDefinition = 
workflowCreateRequest.convert2WorkflowDefinition();
         this.createWorkflowValid(loginUser, workflowDefinition);
 
-        long workflowDefinitionCode;
-        try {
-            workflowDefinitionCode = CodeGenerateUtils.genCode();
-        } catch (CodeGenerateException e) {
-            throw new ServiceException(Status.INTERNAL_SERVER_ERROR_ARGS);
-        }
-
-        workflowDefinition.setCode(workflowDefinitionCode);
+        workflowDefinition.setCode(CodeGenerateUtils.genCode());
         workflowDefinition.setUserId(loginUser.getId());
 
         int create = workflowDefinitionMapper.insert(workflowDefinition);
@@ -1424,7 +1416,7 @@ public class WorkflowDefinitionServiceImpl extends 
BaseServiceImpl implements Wo
     }
 
     private TaskDefinitionLog buildNormalSqlTaskDefinition(String taskName, 
DataSource dataSource,
-                                                           String sql) throws 
CodeGenerateException {
+                                                           String sql) {
         TaskDefinitionLog taskDefinition = new TaskDefinitionLog();
         taskDefinition.setName(taskName);
         taskDefinition.setFlag(Flag.YES);
@@ -1480,15 +1472,8 @@ public class WorkflowDefinitionServiceImpl extends 
BaseServiceImpl implements Wo
         workflowDefinition.setId(null);
         workflowDefinition.setProjectCode(projectCode);
         workflowDefinition.setUserId(loginUser.getId());
-        try {
-            workflowDefinition.setCode(CodeGenerateUtils.genCode());
-        } catch (CodeGenerateException e) {
-            log.error(
-                    "Save workflow definition error because generate workflow 
definition code error, projectCode:{}.",
-                    projectCode, e);
-            putMsg(result, Status.CREATE_WORKFLOW_DEFINITION_ERROR);
-            return false;
-        }
+        workflowDefinition.setCode(CodeGenerateUtils.genCode());
+
         List<TaskDefinition> taskDefinitionList = 
dagDataSchedule.getTaskDefinitionList();
         Map<Long, Long> taskCodeMap = new HashMap<>();
         Date now = new Date();
@@ -1503,16 +1488,10 @@ public class WorkflowDefinitionServiceImpl extends 
BaseServiceImpl implements Wo
             taskDefinitionLog.setUpdateTime(now);
             taskDefinitionLog.setOperator(loginUser.getId());
             taskDefinitionLog.setOperateTime(now);
-            try {
-                long code = CodeGenerateUtils.genCode();
-                taskCodeMap.put(taskDefinitionLog.getCode(), code);
-                taskDefinitionLog.setCode(code);
-            } catch (CodeGenerateException e) {
-                log.error("Generate task definition code error, 
projectCode:{}, workflowDefinitionCode:{}",
-                        projectCode, workflowDefinition.getCode(), e);
-                putMsg(result, Status.INTERNAL_SERVER_ERROR_ARGS, "Error 
generating task definition code");
-                return false;
-            }
+            long code = CodeGenerateUtils.genCode();
+            taskCodeMap.put(taskDefinitionLog.getCode(), code);
+            taskDefinitionLog.setCode(code);
+
             taskDefinitionLogList.add(taskDefinitionLog);
         }
         int insert = taskDefinitionMapper.batchInsert(taskDefinitionLogList);
@@ -2120,15 +2099,8 @@ public class WorkflowDefinitionServiceImpl extends 
BaseServiceImpl implements Wo
                 List<TaskDefinitionLog> taskDefinitionLogs =
                         
taskDefinitionLogDao.queryTaskDefineLogList(workflowTaskRelations);
                 Map<Long, Long> taskCodeMap = new HashMap<>();
-                taskDefinitionLogs.forEach(taskDefinitionLog -> {
-                    try {
-                        taskCodeMap.put(taskDefinitionLog.getCode(), 
CodeGenerateUtils.genCode());
-                    } catch (CodeGenerateException e) {
-                        log.error("Generate task definition code error, 
projectCode:{}.", targetProjectCode, e);
-                        putMsg(result, Status.INTERNAL_SERVER_ERROR_ARGS);
-                        throw new 
ServiceException(Status.INTERNAL_SERVER_ERROR_ARGS);
-                    }
-                });
+                taskDefinitionLogs.forEach(
+                        taskDefinitionLog -> 
taskCodeMap.put(taskDefinitionLog.getCode(), CodeGenerateUtils.genCode()));
                 for (TaskDefinitionLog taskDefinitionLog : taskDefinitionLogs) 
{
                     
taskDefinitionLog.setCode(taskCodeMap.get(taskDefinitionLog.getCode()));
                     taskDefinitionLog.setProjectCode(targetProjectCode);
@@ -2164,13 +2136,8 @@ public class WorkflowDefinitionServiceImpl extends 
BaseServiceImpl implements Wo
                     }
                 }
                 final long oldWorkflowDefinitionCode = 
workflowDefinition.getCode();
-                try {
-                    workflowDefinition.setCode(CodeGenerateUtils.genCode());
-                } catch (CodeGenerateException e) {
-                    log.error("Generate workflow definition code error, 
projectCode:{}.", targetProjectCode, e);
-                    putMsg(result, Status.INTERNAL_SERVER_ERROR_ARGS);
-                    throw new 
ServiceException(Status.INTERNAL_SERVER_ERROR_ARGS);
-                }
+                workflowDefinition.setCode(CodeGenerateUtils.genCode());
+
                 workflowDefinition.setId(null);
                 workflowDefinition.setUserId(loginUser.getId());
                 
workflowDefinition.setName(getNewName(workflowDefinition.getName(), 
COPY_SUFFIX));
diff --git 
a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/python/PythonGatewayTest.java
 
b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/python/PythonGatewayTest.java
index 918f55dfad..10d833a2fd 100644
--- 
a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/python/PythonGatewayTest.java
+++ 
b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/python/PythonGatewayTest.java
@@ -18,7 +18,6 @@
 package org.apache.dolphinscheduler.api.python;
 
 import org.apache.dolphinscheduler.api.service.ResourcesService;
-import org.apache.dolphinscheduler.common.utils.CodeGenerateUtils;
 import org.apache.dolphinscheduler.dao.entity.Project;
 import org.apache.dolphinscheduler.dao.entity.TaskDefinition;
 import org.apache.dolphinscheduler.dao.entity.User;
@@ -62,7 +61,7 @@ public class PythonGatewayTest {
     private ResourcesService resourcesService;
 
     @Test
-    public void testGetCodeAndVersion() throws 
CodeGenerateUtils.CodeGenerateException {
+    public void testGetCodeAndVersion() {
         Project project = getTestProject();
         
Mockito.when(projectMapper.queryByName(project.getName())).thenReturn(project);
 
diff --git 
a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ProjectParameterServiceTest.java
 
b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ProjectParameterServiceTest.java
index c7d6dc73d6..4207bed59d 100644
--- 
a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ProjectParameterServiceTest.java
+++ 
b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ProjectParameterServiceTest.java
@@ -21,6 +21,7 @@ import static 
org.apache.dolphinscheduler.api.utils.ServiceTestUtil.getGeneralUs
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertNotNull;
 import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.ArgumentMatchers.anyLong;
 import static org.mockito.Mockito.when;
@@ -90,9 +91,9 @@ public class ProjectParameterServiceTest {
         try (MockedStatic<CodeGenerateUtils> ignored = 
Mockito.mockStatic(CodeGenerateUtils.class)) {
             
when(CodeGenerateUtils.genCode()).thenThrow(CodeGenerateUtils.CodeGenerateException.class);
 
-            result = projectParameterService.createProjectParameter(loginUser, 
projectCode, "key", "value",
-                    DataType.VARCHAR.name());
-            assertEquals(Status.CREATE_PROJECT_PARAMETER_ERROR.getCode(), 
result.getCode());
+            assertThrows(CodeGenerateUtils.CodeGenerateException.class,
+                    () -> 
projectParameterService.createProjectParameter(loginUser, projectCode, "key", 
"value",
+                            DataType.VARCHAR.name()));
         }
 
         // PROJECT_PARAMETER_ALREADY_EXISTS
diff --git 
a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/impl/EnvironmentServiceTest.java
 
b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/impl/EnvironmentServiceTest.java
index b8161af13d..ba6ffc6792 100644
--- 
a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/impl/EnvironmentServiceTest.java
+++ 
b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/impl/EnvironmentServiceTest.java
@@ -23,6 +23,7 @@ import static 
org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationCon
 import static 
org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.ENVIRONMENT_DELETE;
 import static 
org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.ENVIRONMENT_UPDATE;
 import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.Mockito.when;
 
@@ -140,7 +141,7 @@ public class EnvironmentServiceTest {
         try (MockedStatic<CodeGenerateUtils> ignored = 
Mockito.mockStatic(CodeGenerateUtils.class)) {
             
when(CodeGenerateUtils.genCode()).thenThrow(CodeGenerateUtils.CodeGenerateException.class);
 
-            assertThrowsServiceException(Status.INTERNAL_SERVER_ERROR_ARGS,
+            assertThrows(CodeGenerateUtils.CodeGenerateException.class,
                     () -> environmentService.createEnvironment(adminUser, 
"testName", "test", "test", workerGroups));
         }
     }
diff --git 
a/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java
 
b/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java
index 3d0b317b41..f070cf29e2 100644
--- 
a/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java
+++ 
b/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java
@@ -21,7 +21,6 @@ import 
org.apache.dolphinscheduler.common.enums.AuthorizationType;
 import org.apache.dolphinscheduler.common.enums.TaskGroupQueueStatus;
 import org.apache.dolphinscheduler.common.graph.DAG;
 import org.apache.dolphinscheduler.common.model.TaskNodeRelation;
-import org.apache.dolphinscheduler.common.utils.CodeGenerateUtils;
 import org.apache.dolphinscheduler.dao.entity.Command;
 import org.apache.dolphinscheduler.dao.entity.DagData;
 import org.apache.dolphinscheduler.dao.entity.DataSource;
@@ -46,7 +45,7 @@ import java.util.Optional;
 public interface ProcessService {
 
     WorkflowInstance constructWorkflowInstance(Command command,
-                                               String host) throws 
CronParseException, CodeGenerateUtils.CodeGenerateException;
+                                               String host) throws 
CronParseException;
 
     Optional<WorkflowInstance> findWorkflowInstanceDetailById(int 
workflowInstanceId);
 
diff --git 
a/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java
 
b/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java
index a92c62f57f..a1fa3c51de 100644
--- 
a/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java
+++ 
b/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java
@@ -38,7 +38,6 @@ import 
org.apache.dolphinscheduler.common.enums.WorkflowExecutionStatus;
 import org.apache.dolphinscheduler.common.graph.DAG;
 import org.apache.dolphinscheduler.common.model.TaskNodeRelation;
 import org.apache.dolphinscheduler.common.utils.CodeGenerateUtils;
-import 
org.apache.dolphinscheduler.common.utils.CodeGenerateUtils.CodeGenerateException;
 import org.apache.dolphinscheduler.common.utils.DateUtils;
 import org.apache.dolphinscheduler.common.utils.JSONUtils;
 import org.apache.dolphinscheduler.dao.entity.Cluster;
@@ -492,7 +491,7 @@ public class ProcessServiceImpl implements ProcessService {
      */
     @Override
     public @Nullable WorkflowInstance constructWorkflowInstance(Command 
command,
-                                                                String host) 
throws CronParseException, CodeGenerateException {
+                                                                String host) 
throws CronParseException {
         WorkflowInstance workflowInstance;
         WorkflowDefinition workflowDefinition;
         CommandType commandType = command.getCommandType();
diff --git 
a/dolphinscheduler-tools/src/main/java/org/apache/dolphinscheduler/tools/demo/CreateProcessDemo.java
 
b/dolphinscheduler-tools/src/main/java/org/apache/dolphinscheduler/tools/demo/CreateWorkflowDemo.java
similarity index 80%
rename from 
dolphinscheduler-tools/src/main/java/org/apache/dolphinscheduler/tools/demo/CreateProcessDemo.java
rename to 
dolphinscheduler-tools/src/main/java/org/apache/dolphinscheduler/tools/demo/CreateWorkflowDemo.java
index d071fe2d5c..184d669f3e 100644
--- 
a/dolphinscheduler-tools/src/main/java/org/apache/dolphinscheduler/tools/demo/CreateProcessDemo.java
+++ 
b/dolphinscheduler-tools/src/main/java/org/apache/dolphinscheduler/tools/demo/CreateWorkflowDemo.java
@@ -33,10 +33,10 @@ import org.springframework.stereotype.Component;
                 "org.apache.dolphinscheduler.tools.datasource.*",
         })
 })
-public class CreateProcessDemo {
+public class CreateWorkflowDemo {
 
     public static void main(String[] args) {
-        SpringApplication.run(CreateProcessDemo.class, args);
+        SpringApplication.run(CreateWorkflowDemo.class, args);
     }
 
     @Component
@@ -44,16 +44,16 @@ public class CreateProcessDemo {
     @Slf4j
     static class DemoRunner implements CommandLineRunner {
 
-        private final ProcessDefinitionDemo processDefinitionDemo;
+        private final WorkflowDefinitionDemo workflowDefinitionDemo;
 
-        DemoRunner(ProcessDefinitionDemo processDefinitionDemo) {
-            this.processDefinitionDemo = processDefinitionDemo;
+        DemoRunner(WorkflowDefinitionDemo workflowDefinitionDemo) {
+            this.workflowDefinitionDemo = workflowDefinitionDemo;
         }
 
         @Override
         public void run(String... args) throws Exception {
-            processDefinitionDemo.createProcessDefinitionDemo();
-            log.info("create process definition demo success");
+            workflowDefinitionDemo.createWorkflowDefinitionDemo();
+            log.info("create workflow definition demo success");
         }
     }
 }
diff --git 
a/dolphinscheduler-tools/src/main/java/org/apache/dolphinscheduler/tools/demo/ProxyProcessDefinitionController.java
 
b/dolphinscheduler-tools/src/main/java/org/apache/dolphinscheduler/tools/demo/ProxyWorkflowDefinitionController.java
similarity index 98%
rename from 
dolphinscheduler-tools/src/main/java/org/apache/dolphinscheduler/tools/demo/ProxyProcessDefinitionController.java
rename to 
dolphinscheduler-tools/src/main/java/org/apache/dolphinscheduler/tools/demo/ProxyWorkflowDefinitionController.java
index 27d1037003..c0c9e297ef 100644
--- 
a/dolphinscheduler-tools/src/main/java/org/apache/dolphinscheduler/tools/demo/ProxyProcessDefinitionController.java
+++ 
b/dolphinscheduler-tools/src/main/java/org/apache/dolphinscheduler/tools/demo/ProxyWorkflowDefinitionController.java
@@ -29,7 +29,7 @@ import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 
 @Service
-public class ProxyProcessDefinitionController {
+public class ProxyWorkflowDefinitionController {
 
     @Value("${demo.api-server-port}")
     private String ServerPort;
diff --git 
a/dolphinscheduler-tools/src/main/java/org/apache/dolphinscheduler/tools/demo/ProcessDefinitionDemo.java
 
b/dolphinscheduler-tools/src/main/java/org/apache/dolphinscheduler/tools/demo/WorkflowDefinitionDemo.java
similarity index 92%
rename from 
dolphinscheduler-tools/src/main/java/org/apache/dolphinscheduler/tools/demo/ProcessDefinitionDemo.java
rename to 
dolphinscheduler-tools/src/main/java/org/apache/dolphinscheduler/tools/demo/WorkflowDefinitionDemo.java
index 86e26f898d..434cbaf213 100644
--- 
a/dolphinscheduler-tools/src/main/java/org/apache/dolphinscheduler/tools/demo/ProcessDefinitionDemo.java
+++ 
b/dolphinscheduler-tools/src/main/java/org/apache/dolphinscheduler/tools/demo/WorkflowDefinitionDemo.java
@@ -50,7 +50,7 @@ import org.springframework.stereotype.Component;
 
 @Component
 @Slf4j
-public class ProcessDefinitionDemo {
+public class WorkflowDefinitionDemo {
 
     @Value("${demo.tenant-code}")
     private String tenantCode;
@@ -65,9 +65,9 @@ public class ProcessDefinitionDemo {
     private AccessTokenMapper accessTokenMapper;
 
     @Autowired
-    private ProxyProcessDefinitionController proxyProcessDefinitionController;
+    private ProxyWorkflowDefinitionController 
proxyWorkflowDefinitionController;
 
-    public void createProcessDefinitionDemo() throws Exception {
+    public void createWorkflowDefinitionDemo() throws Exception {
         // get user
         User loginUser = userMapper.selectById("1");
         Date now = new Date();
@@ -81,20 +81,17 @@ public class ProcessDefinitionDemo {
         if (project != null) {
             log.warn("Project {} already exists.", project.getName());
         }
-        try {
-            project = Project
-                    .builder()
-                    .name("demo")
-                    .code(CodeGenerateUtils.genCode())
-                    .description("")
-                    .userId(loginUser.getId())
-                    .userName(loginUser.getUserName())
-                    .createTime(now)
-                    .updateTime(now)
-                    .build();
-        } catch (CodeGenerateUtils.CodeGenerateException e) {
-            log.error("create project error", e);
-        }
+        project = Project
+                .builder()
+                .name("demo")
+                .code(CodeGenerateUtils.genCode())
+                .description("")
+                .userId(loginUser.getId())
+                .userName(loginUser.getUserName())
+                .createTime(now)
+                .updateTime(now)
+                .build();
+
         if (projectMapper.insert(project) > 0) {
             log.info("create project success");
         } else {
@@ -165,13 +162,10 @@ public class ProcessDefinitionDemo {
 
         // get demo taskcode
         List<Long> taskCodes = new ArrayList<>();
-        try {
-            for (int i = 0; i < 1; i++) {
-                taskCodes.add(CodeGenerateUtils.genCode());
-            }
-        } catch (CodeGenerateUtils.CodeGenerateException e) {
-            log.error("task code get error, ", e);
+        for (int i = 0; i < 1; i++) {
+            taskCodes.add(CodeGenerateUtils.genCode());
         }
+
         String taskCodeFirst = 
String.valueOf(taskCodes.get(0)).replaceAll("\\[|\\]", "");
         String absolutePath = System.getProperty("user.dir");
 
@@ -223,7 +217,7 @@ public class ProcessDefinitionDemo {
 
         String taskDefinitionJson = JSONUtils.toJsonString(taskDefinitionLogs);
 
-        ProxyResult ProxyResult = 
proxyProcessDefinitionController.createProcessDefinition(token, projectCode,
+        ProxyResult ProxyResult = 
proxyWorkflowDefinitionController.createProcessDefinition(token, projectCode,
                 processDefinitionLog.getName(),
                 processDefinitionLog.getDescription(),
                 processDefinitionLog.getGlobalParams(),
@@ -240,13 +234,11 @@ public class ProcessDefinitionDemo {
 
         // get demo taskcode
         List<Long> taskCodes = new ArrayList<>();
-        try {
-            for (int i = 0; i < 2; i++) {
-                taskCodes.add(CodeGenerateUtils.genCode());
-            }
-        } catch (CodeGenerateUtils.CodeGenerateException e) {
-            log.error("task code get error, ", e);
+
+        for (int i = 0; i < 2; i++) {
+            taskCodes.add(CodeGenerateUtils.genCode());
         }
+
         String taskCodeFirst = 
String.valueOf(taskCodes.get(0)).replaceAll("\\[|\\]", "");
         String taskCodeSecond = 
String.valueOf(taskCodes.get(1)).replaceAll("\\[|\\]", "");
 
@@ -316,7 +308,7 @@ public class ProcessDefinitionDemo {
         taskDefinitionLogSecond.setTaskType("SHELL");
         String taskDefinitionJson = JSONUtils.toJsonString(taskDefinitionLogs);
 
-        ProxyResult ProxyResult = 
proxyProcessDefinitionController.createProcessDefinition(token, projectCode,
+        ProxyResult ProxyResult = 
proxyWorkflowDefinitionController.createProcessDefinition(token, projectCode,
                 processDefinitionLog.getName(),
                 processDefinitionLog.getDescription(),
                 processDefinitionLog.getGlobalParams(),
@@ -332,13 +324,11 @@ public class ProcessDefinitionDemo {
 
         // get demo taskcode
         List<Long> taskCodes = new ArrayList<>();
-        try {
-            for (int i = 0; i < 2; i++) {
-                taskCodes.add(CodeGenerateUtils.genCode());
-            }
-        } catch (CodeGenerateUtils.CodeGenerateException e) {
-            log.error("task code get error, ", e);
+
+        for (int i = 0; i < 2; i++) {
+            taskCodes.add(CodeGenerateUtils.genCode());
         }
+
         String taskCodeFirst = 
String.valueOf(taskCodes.get(0)).replaceAll("\\[|\\]", "");
         String taskCodeSecond = 
String.valueOf(taskCodes.get(1)).replaceAll("\\[|\\]", "");
 
@@ -402,7 +392,7 @@ public class ProcessDefinitionDemo {
                 "{\"localParams\":[],\"rawScript\":\"echo \\\"====node 
start====\\\"\\r\\n\\r\\necho ${output}\\r\\n\\r\\necho 
${value}\\r\\n\\r\\necho \\\"====Node end====\\\"\",\"resourceList\":[]}");
         String taskDefinitionJson = JSONUtils.toJsonString(taskDefinitionLogs);
 
-        ProxyResult ProxyResult = 
proxyProcessDefinitionController.createProcessDefinition(token, projectCode,
+        ProxyResult ProxyResult = 
proxyWorkflowDefinitionController.createProcessDefinition(token, projectCode,
                 processDefinitionLog.getName(),
                 processDefinitionLog.getDescription(),
                 processDefinitionLog.getGlobalParams(),
@@ -418,13 +408,10 @@ public class ProcessDefinitionDemo {
 
         // get demo taskcode
         List<Long> taskCodes = new ArrayList<>();
-        try {
-            for (int i = 0; i < 4; i++) {
-                taskCodes.add(CodeGenerateUtils.genCode());
-            }
-        } catch (CodeGenerateUtils.CodeGenerateException e) {
-            log.error("task code get error, ", e);
+        for (int i = 0; i < 4; i++) {
+            taskCodes.add(CodeGenerateUtils.genCode());
         }
+
         String taskCodeFirst = 
String.valueOf(taskCodes.get(0)).replaceAll("\\[|\\]", "");
         String taskCodeSecond = 
String.valueOf(taskCodes.get(1)).replaceAll("\\[|\\]", "");
         String taskCodeThird = 
String.valueOf(taskCodes.get(2)).replaceAll("\\[|\\]", "");
@@ -519,7 +506,7 @@ public class ProcessDefinitionDemo {
         taskDefinitionLogFourth.setTaskType("SHELL");
         String taskDefinitionJson = JSONUtils.toJsonString(taskDefinitionLogs);
 
-        ProxyResult ProxyResult = 
proxyProcessDefinitionController.createProcessDefinition(token, projectCode,
+        ProxyResult ProxyResult = 
proxyWorkflowDefinitionController.createProcessDefinition(token, projectCode,
                 processDefinitionLog.getName(),
                 processDefinitionLog.getDescription(),
                 processDefinitionLog.getGlobalParams(),
@@ -535,13 +522,11 @@ public class ProcessDefinitionDemo {
 
         // get demo taskcode
         List<Long> taskCodes = new ArrayList<>();
-        try {
-            for (int i = 0; i < 4; i++) {
-                taskCodes.add(CodeGenerateUtils.genCode());
-            }
-        } catch (CodeGenerateUtils.CodeGenerateException e) {
-            log.error("task code get error, ", e);
+
+        for (int i = 0; i < 4; i++) {
+            taskCodes.add(CodeGenerateUtils.genCode());
         }
+
         String taskCodeFirst = 
String.valueOf(taskCodes.get(0)).replaceAll("\\[|\\]", "");
         String taskCodeSecond = 
String.valueOf(taskCodes.get(1)).replaceAll("\\[|\\]", "");
         String taskCodeThird = 
String.valueOf(taskCodes.get(2)).replaceAll("\\[|\\]", "");
@@ -638,7 +623,7 @@ public class ProcessDefinitionDemo {
         taskDefinitionLogFourth.setTaskType("SHELL");
         String taskDefinitionJson = JSONUtils.toJsonString(taskDefinitionLogs);
 
-        ProxyResult ProxyResult = 
proxyProcessDefinitionController.createProcessDefinition(token, projectCode,
+        ProxyResult ProxyResult = 
proxyWorkflowDefinitionController.createProcessDefinition(token, projectCode,
                 processDefinitionLog.getName(),
                 processDefinitionLog.getDescription(),
                 processDefinitionLog.getGlobalParams(),
@@ -654,13 +639,10 @@ public class ProcessDefinitionDemo {
 
         // get demo taskcode
         List<Long> taskCodes = new ArrayList<>();
-        try {
-            for (int i = 0; i < 3; i++) {
-                taskCodes.add(CodeGenerateUtils.genCode());
-            }
-        } catch (CodeGenerateUtils.CodeGenerateException e) {
-            log.error("task code get error, ", e);
+        for (int i = 0; i < 3; i++) {
+            taskCodes.add(CodeGenerateUtils.genCode());
         }
+
         String taskCodeFirst = 
String.valueOf(taskCodes.get(0)).replaceAll("\\[|\\]", "");
         String taskCodeSecond = 
String.valueOf(taskCodes.get(1)).replaceAll("\\[|\\]", "");
         String taskCodeThird = 
String.valueOf(taskCodes.get(2)).replaceAll("\\[|\\]", "");
@@ -737,7 +719,7 @@ public class ProcessDefinitionDemo {
                 .setTaskParams("{\"localParams\":[],\"rawScript\":\"echo 
\\\"end\\\"\",\"resourceList\":[]}");
         String taskDefinitionJson = JSONUtils.toJsonString(taskDefinitionLogs);
 
-        ProxyResult ProxyResult = 
proxyProcessDefinitionController.createProcessDefinition(token, projectCode,
+        ProxyResult ProxyResult = 
proxyWorkflowDefinitionController.createProcessDefinition(token, projectCode,
                 processDefinitionLog.getName(),
                 processDefinitionLog.getDescription(),
                 processDefinitionLog.getGlobalParams(),
@@ -753,13 +735,10 @@ public class ProcessDefinitionDemo {
 
         // get demo taskcode
         List<Long> taskCodes = new ArrayList<>();
-        try {
-            for (int i = 0; i < 1; i++) {
-                taskCodes.add(CodeGenerateUtils.genCode());
-            }
-        } catch (CodeGenerateUtils.CodeGenerateException e) {
-            log.error("task code get error, ", e);
+        for (int i = 0; i < 1; i++) {
+            taskCodes.add(CodeGenerateUtils.genCode());
         }
+
         String taskCode = 
String.valueOf(taskCodes.get(0)).replaceAll("\\[|\\]", "");
 
         WorkflowDefinitionLog processDefinitionLog = new 
WorkflowDefinitionLog();
@@ -810,7 +789,7 @@ public class ProcessDefinitionDemo {
 
         String taskDefinitionJson = JSONUtils.toJsonString(taskDefinitionLogs);
 
-        ProxyResult ProxyResult = 
proxyProcessDefinitionController.createProcessDefinition(token, projectCode,
+        ProxyResult ProxyResult = 
proxyWorkflowDefinitionController.createProcessDefinition(token, projectCode,
                 processDefinitionLog.getName(),
                 processDefinitionLog.getDescription(),
                 processDefinitionLog.getGlobalParams(),


Reply via email to