status
stringclasses
1 value
repo_name
stringclasses
31 values
repo_url
stringclasses
31 values
issue_id
int64
1
104k
title
stringlengths
4
233
body
stringlengths
0
186k
issue_url
stringlengths
38
56
pull_url
stringlengths
37
54
before_fix_sha
stringlengths
40
40
after_fix_sha
stringlengths
40
40
report_datetime
timestamp[us, tz=UTC]
language
stringclasses
5 values
commit_datetime
timestamp[us, tz=UTC]
updated_file
stringlengths
7
188
chunk_content
stringlengths
1
1.03M
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,320
[Bug] [API] batch delete process definition bug
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened batch delete process definition fail ### What you expected to happen batch delete process definition success ### How to reproduce batch delete process definition ### Anything else _No response_ ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6320
https://github.com/apache/dolphinscheduler/pull/6321
c4375a54c167f8e96d80c3cc67ad0a607ba2ef7b
99f593cf42d6abd4312c74511f60ac8a2eeafb25
2021-09-23T12:44:06Z
java
2021-09-23T14:43:15Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java
putMsg(result, Status.TASK_DEFINE_NOT_EXIST, StringUtils.join(codes, Constants.COMMA)); return result; } } if (graphHasCycle(taskNodeList)) { logger.error("process DAG has cycle"); putMsg(result, Status.PROCESS_NODE_HAS_CYCLE); return result; } for (ProcessTaskRelationLog processTaskRelationLog : taskRelationList) { if (processTaskRelationLog.getPostTaskCode() == 0) { logger.error("the post_task_code or post_task_version can't be zero"); putMsg(result, Status.CHECK_PROCESS_TASK_RELATION_ERROR); return result; } } putMsg(result, Status.SUCCESS); } catch (Exception e) { result.put(Constants.STATUS, Status.REQUEST_PARAMS_NOT_VALID_ERROR); result.put(Constants.MSG, e.getMessage()); } return result; } /** * query process definition list * * @param loginUser login user * @param projectCode project code * @return definition list
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,320
[Bug] [API] batch delete process definition bug
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened batch delete process definition fail ### What you expected to happen batch delete process definition success ### How to reproduce batch delete process definition ### Anything else _No response_ ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6320
https://github.com/apache/dolphinscheduler/pull/6321
c4375a54c167f8e96d80c3cc67ad0a607ba2ef7b
99f593cf42d6abd4312c74511f60ac8a2eeafb25
2021-09-23T12:44:06Z
java
2021-09-23T14:43:15Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java
*/ @Override public Map<String, Object> queryProcessDefinitionList(User loginUser, long projectCode) { Project project = projectMapper.queryByCode(projectCode); Map<String, Object> result = projectService.checkProjectAndAuth(loginUser, project, projectCode); if (result.get(Constants.STATUS) != Status.SUCCESS) { return result; } List<ProcessDefinition> resourceList = processDefinitionMapper.queryAllDefinitionList(projectCode); List<DagData> dagDataList = resourceList.stream().map(processService::genDagData).collect(Collectors.toList()); result.put(Constants.DATA_LIST, dagDataList); putMsg(result, Status.SUCCESS); return result; } /** * query process definition list paging * * @param loginUser login user * @param projectCode project code * @param searchVal search value * @param userId user id * @param pageNo page number * @param pageSize page size * @return process definition page */ @Override public Result queryProcessDefinitionListPaging(User loginUser, long projectCode, String searchVal, Integer userId, Integer pageNo, Integer pageSize) { Result result = new Result(); Project project = projectMapper.queryByCode(projectCode);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,320
[Bug] [API] batch delete process definition bug
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened batch delete process definition fail ### What you expected to happen batch delete process definition success ### How to reproduce batch delete process definition ### Anything else _No response_ ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6320
https://github.com/apache/dolphinscheduler/pull/6321
c4375a54c167f8e96d80c3cc67ad0a607ba2ef7b
99f593cf42d6abd4312c74511f60ac8a2eeafb25
2021-09-23T12:44:06Z
java
2021-09-23T14:43:15Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java
Map<String, Object> checkResult = projectService.checkProjectAndAuth(loginUser, project, projectCode); Status resultStatus = (Status) checkResult.get(Constants.STATUS); if (resultStatus != Status.SUCCESS) { putMsg(result, resultStatus); return result; } Page<ProcessDefinition> page = new Page<>(pageNo, pageSize); IPage<ProcessDefinition> processDefinitionIPage = processDefinitionMapper.queryDefineListPaging( page, searchVal, userId, project.getCode(), isAdmin(loginUser)); List<ProcessDefinition> records = processDefinitionIPage.getRecords(); for (ProcessDefinition pd : records) { ProcessDefinitionLog processDefinitionLog = processDefinitionLogMapper.queryByDefinitionCodeAndVersion(pd.getCode(), pd.getVersion()); User user = userMapper.selectById(processDefinitionLog.getOperator()); pd.setModifyBy(user.getUserName()); } processDefinitionIPage.setRecords(records); PageInfo<ProcessDefinition> pageInfo = new PageInfo<>(pageNo, pageSize); pageInfo.setTotal((int) processDefinitionIPage.getTotal()); pageInfo.setTotalList(processDefinitionIPage.getRecords()); result.setData(pageInfo); putMsg(result, Status.SUCCESS); return result; } /** * query detail of process definition * * @param loginUser login user * @param projectCode project code * @param code process definition code
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,320
[Bug] [API] batch delete process definition bug
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened batch delete process definition fail ### What you expected to happen batch delete process definition success ### How to reproduce batch delete process definition ### Anything else _No response_ ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6320
https://github.com/apache/dolphinscheduler/pull/6321
c4375a54c167f8e96d80c3cc67ad0a607ba2ef7b
99f593cf42d6abd4312c74511f60ac8a2eeafb25
2021-09-23T12:44:06Z
java
2021-09-23T14:43:15Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java
* @return process definition detail */ @Override public Map<String, Object> queryProcessDefinitionByCode(User loginUser, long projectCode, long code) { Project project = projectMapper.queryByCode(projectCode); Map<String, Object> result = projectService.checkProjectAndAuth(loginUser, project, projectCode); if (result.get(Constants.STATUS) != Status.SUCCESS) { return result; } ProcessDefinition processDefinition = processDefinitionMapper.queryByCode(code); if (processDefinition == null) { putMsg(result, Status.PROCESS_DEFINE_NOT_EXIST, code); } else { Tenant tenant = tenantMapper.queryById(processDefinition.getTenantId()); if (tenant != null) { processDefinition.setTenantCode(tenant.getTenantCode()); } DagData dagData = processService.genDagData(processDefinition); result.put(Constants.DATA_LIST, dagData); putMsg(result, Status.SUCCESS); } return result; } @Override public Map<String, Object> queryProcessDefinitionByName(User loginUser, long projectCode, String name) { Project project = projectMapper.queryByCode(projectCode); Map<String, Object> result = projectService.checkProjectAndAuth(loginUser, project, projectCode); if (result.get(Constants.STATUS) != Status.SUCCESS) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,320
[Bug] [API] batch delete process definition bug
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened batch delete process definition fail ### What you expected to happen batch delete process definition success ### How to reproduce batch delete process definition ### Anything else _No response_ ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6320
https://github.com/apache/dolphinscheduler/pull/6321
c4375a54c167f8e96d80c3cc67ad0a607ba2ef7b
99f593cf42d6abd4312c74511f60ac8a2eeafb25
2021-09-23T12:44:06Z
java
2021-09-23T14:43:15Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java
return result; } ProcessDefinition processDefinition = processDefinitionMapper.queryByDefineName(projectCode, name); if (processDefinition == null) { putMsg(result, Status.PROCESS_DEFINE_NOT_EXIST, name); } else { DagData dagData = processService.genDagData(processDefinition); result.put(Constants.DATA_LIST, dagData); putMsg(result, Status.SUCCESS); } return result; } /** * update process definition * * @param loginUser login user * @param projectCode project code * @param name process definition name * @param code process definition code * @param description description * @param globalParams global params * @param locations locations for nodes * @param timeout timeout * @param tenantCode tenantCode * @param taskRelationJson relation json for nodes * @param taskDefinitionJson taskDefinitionJson * @return update result code */ @Override @Transactional(rollbackFor = RuntimeException.class)
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,320
[Bug] [API] batch delete process definition bug
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened batch delete process definition fail ### What you expected to happen batch delete process definition success ### How to reproduce batch delete process definition ### Anything else _No response_ ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6320
https://github.com/apache/dolphinscheduler/pull/6321
c4375a54c167f8e96d80c3cc67ad0a607ba2ef7b
99f593cf42d6abd4312c74511f60ac8a2eeafb25
2021-09-23T12:44:06Z
java
2021-09-23T14:43:15Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java
public Map<String, Object> updateProcessDefinition(User loginUser, long projectCode, String name, long code, String description, String globalParams, String locations, int timeout, String tenantCode, String taskRelationJson, String taskDefinitionJson) { Project project = projectMapper.queryByCode(projectCode); Map<String, Object> result = projectService.checkProjectAndAuth(loginUser, project, projectCode); if (result.get(Constants.STATUS) != Status.SUCCESS) { return result; } List<TaskDefinitionLog> taskDefinitionLogs = JSONUtils.toList(taskDefinitionJson, TaskDefinitionLog.class); Map<String, Object> checkTaskDefinitions = checkTaskDefinitionList(taskDefinitionLogs, taskDefinitionJson); if (checkTaskDefinitions.get(Constants.STATUS) != Status.SUCCESS) { return checkTaskDefinitions; } List<ProcessTaskRelationLog> taskRelationList = JSONUtils.toList(taskRelationJson, ProcessTaskRelationLog.class); Map<String, Object> checkRelationJson = checkTaskRelationList(taskRelationList, taskRelationJson, taskDefinitionLogs); if (checkRelationJson.get(Constants.STATUS) != Status.SUCCESS) { return checkRelationJson; } int tenantId = -1; if (!Constants.DEFAULT.equals(tenantCode)) { Tenant tenant = tenantMapper.queryByTenantCode(tenantCode);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,320
[Bug] [API] batch delete process definition bug
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened batch delete process definition fail ### What you expected to happen batch delete process definition success ### How to reproduce batch delete process definition ### Anything else _No response_ ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6320
https://github.com/apache/dolphinscheduler/pull/6321
c4375a54c167f8e96d80c3cc67ad0a607ba2ef7b
99f593cf42d6abd4312c74511f60ac8a2eeafb25
2021-09-23T12:44:06Z
java
2021-09-23T14:43:15Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java
if (tenant == null) { putMsg(result, Status.TENANT_NOT_EXIST); return result; } tenantId = tenant.getId(); } ProcessDefinition processDefinition = processDefinitionMapper.queryByCode(code); if (processDefinition == null) { putMsg(result, Status.PROCESS_DEFINE_NOT_EXIST, code); return result; } if (processDefinition.getReleaseState() == ReleaseState.ONLINE) { putMsg(result, Status.PROCESS_DEFINE_NOT_ALLOWED_EDIT, processDefinition.getName()); return result; } if (!name.equals(processDefinition.getName())) { ProcessDefinition definition = processDefinitionMapper.verifyByDefineName(project.getCode(), name); if (definition != null) { putMsg(result, Status.PROCESS_DEFINITION_NAME_EXIST, name); return result; } } ProcessDefinition processDefinitionDeepCopy = JSONUtils.parseObject(JSONUtils.toJsonString(processDefinition), ProcessDefinition.class); processDefinition.set(projectCode, name, description, globalParams, locations, timeout, tenantId); return updateDagDefine(loginUser, taskRelationList, processDefinition, processDefinitionDeepCopy, taskDefinitionLogs); } private Map<String, Object> updateDagDefine(User loginUser,
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,320
[Bug] [API] batch delete process definition bug
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened batch delete process definition fail ### What you expected to happen batch delete process definition success ### How to reproduce batch delete process definition ### Anything else _No response_ ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6320
https://github.com/apache/dolphinscheduler/pull/6321
c4375a54c167f8e96d80c3cc67ad0a607ba2ef7b
99f593cf42d6abd4312c74511f60ac8a2eeafb25
2021-09-23T12:44:06Z
java
2021-09-23T14:43:15Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java
List<ProcessTaskRelationLog> taskRelationList, ProcessDefinition processDefinition, ProcessDefinition processDefinitionDeepCopy, List<TaskDefinitionLog> taskDefinitionLogs) { Map<String, Object> result = new HashMap<>(); int saveTaskResult = processService.saveTaskDefine(loginUser, processDefinition.getProjectCode(), taskDefinitionLogs); if (saveTaskResult == Constants.EXIT_CODE_SUCCESS) { logger.info("The task has not changed, so skip"); } if (saveTaskResult == Constants.DEFINITION_FAILURE) { putMsg(result, Status.UPDATE_TASK_DEFINITION_ERROR); throw new ServiceException(Status.UPDATE_TASK_DEFINITION_ERROR); } int insertVersion; if (processDefinition.equals(processDefinitionDeepCopy)) { insertVersion = processDefinitionDeepCopy.getVersion(); } else { processDefinition.setUpdateTime(new Date()); insertVersion = processService.saveProcessDefine(loginUser, processDefinition, true); } if (insertVersion == 0) { putMsg(result, Status.UPDATE_PROCESS_DEFINITION_ERROR); throw new ServiceException(Status.UPDATE_PROCESS_DEFINITION_ERROR); } int insertResult = processService.saveTaskRelation(loginUser, processDefinition.getProjectCode(), processDefinition.getCode(), insertVersion, taskRelationList, taskDefinitionLogs); if (insertResult == Constants.EXIT_CODE_SUCCESS) { putMsg(result, Status.SUCCESS); result.put(Constants.DATA_LIST, processDefinition); } else {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,320
[Bug] [API] batch delete process definition bug
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened batch delete process definition fail ### What you expected to happen batch delete process definition success ### How to reproduce batch delete process definition ### Anything else _No response_ ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6320
https://github.com/apache/dolphinscheduler/pull/6321
c4375a54c167f8e96d80c3cc67ad0a607ba2ef7b
99f593cf42d6abd4312c74511f60ac8a2eeafb25
2021-09-23T12:44:06Z
java
2021-09-23T14:43:15Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java
putMsg(result, Status.UPDATE_PROCESS_DEFINITION_ERROR); throw new ServiceException(Status.UPDATE_PROCESS_DEFINITION_ERROR); } return result; } /** * verify process definition name unique * * @param loginUser login user * @param projectCode project code * @param name name * @return true if process definition name not exists, otherwise false */ @Override public Map<String, Object> verifyProcessDefinitionName(User loginUser, long projectCode, String name) { Project project = projectMapper.queryByCode(projectCode); Map<String, Object> result = projectService.checkProjectAndAuth(loginUser, project, projectCode); if (result.get(Constants.STATUS) != Status.SUCCESS) { return result; } ProcessDefinition processDefinition = processDefinitionMapper.verifyByDefineName(project.getCode(), name.trim()); if (processDefinition == null) { putMsg(result, Status.SUCCESS); } else { putMsg(result, Status.PROCESS_DEFINITION_NAME_EXIST, name.trim()); } return result; } /**
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,320
[Bug] [API] batch delete process definition bug
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened batch delete process definition fail ### What you expected to happen batch delete process definition success ### How to reproduce batch delete process definition ### Anything else _No response_ ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6320
https://github.com/apache/dolphinscheduler/pull/6321
c4375a54c167f8e96d80c3cc67ad0a607ba2ef7b
99f593cf42d6abd4312c74511f60ac8a2eeafb25
2021-09-23T12:44:06Z
java
2021-09-23T14:43:15Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java
* delete process definition by code * * @param loginUser login user * @param projectCode project code * @param code process definition code * @return delete result code */ @Override @Transactional(rollbackFor = RuntimeException.class) public Map<String, Object> deleteProcessDefinitionByCode(User loginUser, long projectCode, long code) { Project project = projectMapper.queryByCode(projectCode); Map<String, Object> result = projectService.checkProjectAndAuth(loginUser, project, projectCode); if (result.get(Constants.STATUS) != Status.SUCCESS) { return result; } ProcessDefinition processDefinition = processDefinitionMapper.queryByCode(code); if (processDefinition == null) { putMsg(result, Status.PROCESS_DEFINE_NOT_EXIST, code); return result; } if (loginUser.getId() != processDefinition.getUserId() && loginUser.getUserType() != UserType.ADMIN_USER) { putMsg(result, Status.USER_NO_OPERATION_PERM); return result; } if (processDefinition.getReleaseState() == ReleaseState.ONLINE) { putMsg(result, Status.PROCESS_DEFINE_STATE_ONLINE, code); return result;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,320
[Bug] [API] batch delete process definition bug
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened batch delete process definition fail ### What you expected to happen batch delete process definition success ### How to reproduce batch delete process definition ### Anything else _No response_ ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6320
https://github.com/apache/dolphinscheduler/pull/6321
c4375a54c167f8e96d80c3cc67ad0a607ba2ef7b
99f593cf42d6abd4312c74511f60ac8a2eeafb25
2021-09-23T12:44:06Z
java
2021-09-23T14:43:15Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java
} List<ProcessInstance> processInstances = processInstanceService.queryByProcessDefineCodeAndStatus(processDefinition.getCode(), Constants.NOT_TERMINATED_STATES); if (CollectionUtils.isNotEmpty(processInstances)) { putMsg(result, Status.DELETE_PROCESS_DEFINITION_BY_CODE_FAIL, processInstances.size()); return result; } List<Schedule> schedules = scheduleMapper.queryByProcessDefinitionCode(code); if (!schedules.isEmpty() && schedules.size() > 1) { logger.warn("scheduler num is {},Greater than 1", schedules.size()); putMsg(result, Status.DELETE_PROCESS_DEFINE_BY_CODE_ERROR); return result; } else if (schedules.size() == 1) { Schedule schedule = schedules.get(0); if (schedule.getReleaseState() == ReleaseState.OFFLINE) { int delete = scheduleMapper.deleteById(schedule.getId()); if (delete == 0) { putMsg(result, Status.DELETE_SCHEDULE_CRON_BY_ID_ERROR); throw new ServiceException(Status.DELETE_SCHEDULE_CRON_BY_ID_ERROR); } } else if (schedule.getReleaseState() == ReleaseState.ONLINE) { putMsg(result, Status.SCHEDULE_CRON_STATE_ONLINE, schedule.getId()); return result; } } int delete = processDefinitionMapper.deleteById(processDefinition.getId()); int deleteRelation = processTaskRelationMapper.deleteByCode(project.getCode(), processDefinition.getCode()); if ((delete & deleteRelation) == 0) { putMsg(result, Status.DELETE_PROCESS_DEFINE_BY_CODE_ERROR);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,320
[Bug] [API] batch delete process definition bug
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened batch delete process definition fail ### What you expected to happen batch delete process definition success ### How to reproduce batch delete process definition ### Anything else _No response_ ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6320
https://github.com/apache/dolphinscheduler/pull/6321
c4375a54c167f8e96d80c3cc67ad0a607ba2ef7b
99f593cf42d6abd4312c74511f60ac8a2eeafb25
2021-09-23T12:44:06Z
java
2021-09-23T14:43:15Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java
throw new ServiceException(Status.DELETE_PROCESS_DEFINE_BY_CODE_ERROR); } putMsg(result, Status.SUCCESS); return result; } /** * release process definition: online / offline * * @param loginUser login user * @param projectCode project code * @param code process definition code * @param releaseState release state * @return release result code */ @Override @Transactional(rollbackFor = RuntimeException.class) public Map<String, Object> releaseProcessDefinition(User loginUser, long projectCode, long code, ReleaseState releaseState) { Project project = projectMapper.queryByCode(projectCode); Map<String, Object> result = projectService.checkProjectAndAuth(loginUser, project, projectCode); if (result.get(Constants.STATUS) != Status.SUCCESS) { return result; } if (null == releaseState) { putMsg(result, Status.REQUEST_PARAMS_NOT_VALID_ERROR, RELEASESTATE); return result; } ProcessDefinition processDefinition = processDefinitionMapper.queryByCode(code); switch (releaseState) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,320
[Bug] [API] batch delete process definition bug
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened batch delete process definition fail ### What you expected to happen batch delete process definition success ### How to reproduce batch delete process definition ### Anything else _No response_ ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6320
https://github.com/apache/dolphinscheduler/pull/6321
c4375a54c167f8e96d80c3cc67ad0a607ba2ef7b
99f593cf42d6abd4312c74511f60ac8a2eeafb25
2021-09-23T12:44:06Z
java
2021-09-23T14:43:15Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java
case ONLINE: String resourceIds = processDefinition.getResourceIds(); if (StringUtils.isNotBlank(resourceIds)) { Integer[] resourceIdArray = Arrays.stream(resourceIds.split(Constants.COMMA)).map(Integer::parseInt).toArray(Integer[]::new); PermissionCheck<Integer> permissionCheck = new PermissionCheck<>(AuthorizationType.RESOURCE_FILE_ID, processService, resourceIdArray, loginUser.getId(), logger); try { permissionCheck.checkPermission(); } catch (Exception e) { logger.error(e.getMessage(), e); putMsg(result, Status.RESOURCE_NOT_EXIST_OR_NO_PERMISSION, RELEASESTATE); return result; } } processDefinition.setReleaseState(releaseState); processDefinitionMapper.updateById(processDefinition); break; case OFFLINE: processDefinition.setReleaseState(releaseState); int updateProcess = processDefinitionMapper.updateById(processDefinition); List<Schedule> scheduleList = scheduleMapper.selectAllByProcessDefineArray( new long[]{processDefinition.getCode()} ); if (updateProcess > 0 && scheduleList.size() == 1) { Schedule schedule = scheduleList.get(0); logger.info("set schedule offline, project id: {}, schedule id: {}, process definition code: {}", project.getId(), schedule.getId(), code); schedule.setReleaseState(ReleaseState.OFFLINE); int updateSchedule = scheduleMapper.updateById(schedule); if (updateSchedule == 0) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,320
[Bug] [API] batch delete process definition bug
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened batch delete process definition fail ### What you expected to happen batch delete process definition success ### How to reproduce batch delete process definition ### Anything else _No response_ ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6320
https://github.com/apache/dolphinscheduler/pull/6321
c4375a54c167f8e96d80c3cc67ad0a607ba2ef7b
99f593cf42d6abd4312c74511f60ac8a2eeafb25
2021-09-23T12:44:06Z
java
2021-09-23T14:43:15Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java
putMsg(result, Status.OFFLINE_SCHEDULE_ERROR); throw new ServiceException(Status.OFFLINE_SCHEDULE_ERROR); } schedulerService.deleteSchedule(project.getId(), schedule.getId()); } break; default: putMsg(result, Status.REQUEST_PARAMS_NOT_VALID_ERROR, RELEASESTATE); return result; } putMsg(result, Status.SUCCESS); return result; } /** * batch export process definition by codes */ @Override public void batchExportProcessDefinitionByCodes(User loginUser, long projectCode, String codes, HttpServletResponse response) { if (StringUtils.isEmpty(codes)) { return; } Project project = projectMapper.queryByCode(projectCode); Map<String, Object> result = projectService.checkProjectAndAuth(loginUser, project, projectCode); if (result.get(Constants.STATUS) != Status.SUCCESS) { return; } Set<Long> defineCodeSet = Lists.newArrayList(codes.split(Constants.COMMA)).stream().map(Long::parseLong).collect(Collectors.toSet()); List<ProcessDefinition> processDefinitionList = processDefinitionMapper.queryByCodes(defineCodeSet); List<DagDataSchedule> dagDataSchedules = processDefinitionList.stream().map(this::exportProcessDagData).collect(Collectors.toList());
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,320
[Bug] [API] batch delete process definition bug
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened batch delete process definition fail ### What you expected to happen batch delete process definition success ### How to reproduce batch delete process definition ### Anything else _No response_ ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6320
https://github.com/apache/dolphinscheduler/pull/6321
c4375a54c167f8e96d80c3cc67ad0a607ba2ef7b
99f593cf42d6abd4312c74511f60ac8a2eeafb25
2021-09-23T12:44:06Z
java
2021-09-23T14:43:15Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java
if (CollectionUtils.isNotEmpty(dagDataSchedules)) { downloadProcessDefinitionFile(response, dagDataSchedules); } } /** * download the process definition file */ private void downloadProcessDefinitionFile(HttpServletResponse response, List<DagDataSchedule> dagDataSchedules) { response.setContentType(MediaType.APPLICATION_JSON_UTF8_VALUE); BufferedOutputStream buff = null; ServletOutputStream out = null; try { out = response.getOutputStream(); buff = new BufferedOutputStream(out); buff.write(JSONUtils.toJsonString(dagDataSchedules).getBytes(StandardCharsets.UTF_8)); buff.flush(); buff.close(); } catch (IOException e) { logger.warn("export process fail", e); } finally { if (null != buff) { try { buff.close(); } catch (Exception e) { logger.warn("export process buffer not close", e); } } if (null != out) { try { out.close();
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,320
[Bug] [API] batch delete process definition bug
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened batch delete process definition fail ### What you expected to happen batch delete process definition success ### How to reproduce batch delete process definition ### Anything else _No response_ ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6320
https://github.com/apache/dolphinscheduler/pull/6321
c4375a54c167f8e96d80c3cc67ad0a607ba2ef7b
99f593cf42d6abd4312c74511f60ac8a2eeafb25
2021-09-23T12:44:06Z
java
2021-09-23T14:43:15Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java
} catch (Exception e) { logger.warn("export process output stream not close", e); } } } } /** * get export process dag data * * @param processDefinition process definition * @return DagDataSchedule */ public DagDataSchedule exportProcessDagData(ProcessDefinition processDefinition) { List<Schedule> schedules = scheduleMapper.queryByProcessDefinitionCode(processDefinition.getCode()); DagDataSchedule dagDataSchedule = new DagDataSchedule(processService.genDagData(processDefinition)); if (!schedules.isEmpty()) { Schedule schedule = schedules.get(0); schedule.setReleaseState(ReleaseState.OFFLINE); dagDataSchedule.setSchedule(schedule); } return dagDataSchedule; } /** * import process definition * * @param loginUser login user * @param projectCode project code * @param file process metadata json file * @return import process */
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,320
[Bug] [API] batch delete process definition bug
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened batch delete process definition fail ### What you expected to happen batch delete process definition success ### How to reproduce batch delete process definition ### Anything else _No response_ ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6320
https://github.com/apache/dolphinscheduler/pull/6321
c4375a54c167f8e96d80c3cc67ad0a607ba2ef7b
99f593cf42d6abd4312c74511f60ac8a2eeafb25
2021-09-23T12:44:06Z
java
2021-09-23T14:43:15Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java
@Override @Transactional(rollbackFor = RuntimeException.class) public Map<String, Object> importProcessDefinition(User loginUser, long projectCode, MultipartFile file) { Map<String, Object> result = new HashMap<>(); String dagDataScheduleJson = FileUtils.file2String(file); List<DagDataSchedule> dagDataScheduleList = JSONUtils.toList(dagDataScheduleJson, DagDataSchedule.class); if (CollectionUtils.isEmpty(dagDataScheduleList)) { putMsg(result, Status.DATA_IS_NULL, "fileContent"); return result; } for (DagDataSchedule dagDataSchedule : dagDataScheduleList) { if (!checkAndImport(loginUser, projectCode, result, dagDataSchedule)) { return result; } } return result; } /** * check and import */ private boolean checkAndImport(User loginUser, long projectCode, Map<String, Object> result, DagDataSchedule dagDataSchedule) { if (!checkImportanceParams(dagDataSchedule, result)) { return false; } ProcessDefinition processDefinition = dagDataSchedule.getProcessDefinition(); Map<String, Object> checkResult = verifyProcessDefinitionName(loginUser, projectCode, processDefinition.getName()); if (Status.SUCCESS.equals(checkResult.get(Constants.STATUS))) { putMsg(result, Status.SUCCESS);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,320
[Bug] [API] batch delete process definition bug
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened batch delete process definition fail ### What you expected to happen batch delete process definition success ### How to reproduce batch delete process definition ### Anything else _No response_ ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6320
https://github.com/apache/dolphinscheduler/pull/6321
c4375a54c167f8e96d80c3cc67ad0a607ba2ef7b
99f593cf42d6abd4312c74511f60ac8a2eeafb25
2021-09-23T12:44:06Z
java
2021-09-23T14:43:15Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java
} else { result.putAll(checkResult); return false; } String processDefinitionName = recursionProcessDefinitionName(projectCode, processDefinition.getName(), 1); processDefinition.setName(processDefinitionName + "_import_" + DateUtils.getCurrentTimeStamp()); processDefinition.setUserId(loginUser.getId()); try { processDefinition.setCode(SnowFlakeUtils.getInstance().nextId()); } catch (SnowFlakeException e) { putMsg(result, Status.CREATE_PROCESS_DEFINITION_ERROR); return false; } List<TaskDefinition> taskDefinitionList = dagDataSchedule.getTaskDefinitionList(); Map<Long, Long> taskCodeMap = new HashMap<>(); Date now = new Date(); List<TaskDefinitionLog> taskDefinitionLogList = new ArrayList<>(); for (TaskDefinition taskDefinition : taskDefinitionList) { TaskDefinitionLog taskDefinitionLog = new TaskDefinitionLog(taskDefinition); taskDefinitionLog.setName(taskDefinitionLog.getName() + "_import_" + DateUtils.getCurrentTimeStamp()); taskDefinitionLog.setProjectCode(projectCode); taskDefinitionLog.setUserId(loginUser.getId()); taskDefinitionLog.setVersion(Constants.VERSION_FIRST); taskDefinitionLog.setCreateTime(now); taskDefinitionLog.setUpdateTime(now); taskDefinitionLog.setOperator(loginUser.getId()); taskDefinitionLog.setOperateTime(now); try { long code = SnowFlakeUtils.getInstance().nextId(); taskCodeMap.put(taskDefinitionLog.getCode(), code);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,320
[Bug] [API] batch delete process definition bug
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened batch delete process definition fail ### What you expected to happen batch delete process definition success ### How to reproduce batch delete process definition ### Anything else _No response_ ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6320
https://github.com/apache/dolphinscheduler/pull/6321
c4375a54c167f8e96d80c3cc67ad0a607ba2ef7b
99f593cf42d6abd4312c74511f60ac8a2eeafb25
2021-09-23T12:44:06Z
java
2021-09-23T14:43:15Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java
taskDefinitionLog.setCode(code); } catch (SnowFlakeException e) { logger.error("Task code get error, ", e); putMsg(result, Status.INTERNAL_SERVER_ERROR_ARGS, "Error generating task definition code"); return false; } taskDefinitionLogList.add(taskDefinitionLog); } int insert = taskDefinitionMapper.batchInsert(taskDefinitionLogList); int logInsert = taskDefinitionLogMapper.batchInsert(taskDefinitionLogList); if ((logInsert & insert) == 0) { putMsg(result, Status.CREATE_TASK_DEFINITION_ERROR); throw new ServiceException(Status.CREATE_TASK_DEFINITION_ERROR); } List<ProcessTaskRelation> taskRelationList = dagDataSchedule.getProcessTaskRelationList(); List<ProcessTaskRelationLog> taskRelationLogList = new ArrayList<>(); for (ProcessTaskRelation processTaskRelation : taskRelationList) { ProcessTaskRelationLog processTaskRelationLog = new ProcessTaskRelationLog(processTaskRelation); processTaskRelationLog.setPreTaskCode(taskCodeMap.get(processTaskRelationLog.getPreTaskCode())); processTaskRelationLog.setPostTaskCode(taskCodeMap.get(processTaskRelationLog.getPostTaskCode())); processTaskRelationLog.setPreTaskVersion(Constants.VERSION_FIRST); processTaskRelationLog.setPostTaskVersion(Constants.VERSION_FIRST); taskRelationLogList.add(processTaskRelationLog); } Map<String, Object> createDagResult = createDagDefine(loginUser, taskRelationLogList, processDefinition, Lists.newArrayList()); if (Status.SUCCESS.equals(createDagResult.get(Constants.STATUS))) { putMsg(createDagResult, Status.SUCCESS); } else { result.putAll(createDagResult); throw new ServiceException(Status.IMPORT_PROCESS_DEFINE_ERROR);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,320
[Bug] [API] batch delete process definition bug
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened batch delete process definition fail ### What you expected to happen batch delete process definition success ### How to reproduce batch delete process definition ### Anything else _No response_ ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6320
https://github.com/apache/dolphinscheduler/pull/6321
c4375a54c167f8e96d80c3cc67ad0a607ba2ef7b
99f593cf42d6abd4312c74511f60ac8a2eeafb25
2021-09-23T12:44:06Z
java
2021-09-23T14:43:15Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java
} Schedule schedule = dagDataSchedule.getSchedule(); if (null != schedule) { ProcessDefinition newProcessDefinition = processDefinitionMapper.queryByCode(processDefinition.getCode()); schedule.setProcessDefinitionCode(newProcessDefinition.getCode()); schedule.setUserId(loginUser.getId()); schedule.setCreateTime(now); schedule.setUpdateTime(now); int scheduleInsert = scheduleMapper.insert(schedule); if (0 == scheduleInsert) { putMsg(result, Status.IMPORT_PROCESS_DEFINE_ERROR); throw new ServiceException(Status.IMPORT_PROCESS_DEFINE_ERROR); } } return true; } /** * check importance params */ private boolean checkImportanceParams(DagDataSchedule dagDataSchedule, Map<String, Object> result) { if (dagDataSchedule.getProcessDefinition() == null) { putMsg(result, Status.DATA_IS_NULL, "ProcessDefinition"); return false; } if (CollectionUtils.isEmpty(dagDataSchedule.getTaskDefinitionList())) { putMsg(result, Status.DATA_IS_NULL, "TaskDefinitionList"); return false; } if (CollectionUtils.isEmpty(dagDataSchedule.getProcessTaskRelationList())) { putMsg(result, Status.DATA_IS_NULL, "ProcessTaskRelationList");
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,320
[Bug] [API] batch delete process definition bug
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened batch delete process definition fail ### What you expected to happen batch delete process definition success ### How to reproduce batch delete process definition ### Anything else _No response_ ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6320
https://github.com/apache/dolphinscheduler/pull/6321
c4375a54c167f8e96d80c3cc67ad0a607ba2ef7b
99f593cf42d6abd4312c74511f60ac8a2eeafb25
2021-09-23T12:44:06Z
java
2021-09-23T14:43:15Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java
return false; } return true; } private String recursionProcessDefinitionName(long projectCode, String processDefinitionName, int num) { ProcessDefinition processDefinition = processDefinitionMapper.queryByDefineName(projectCode, processDefinitionName); if (processDefinition != null) { if (num > 1) { String str = processDefinitionName.substring(0, processDefinitionName.length() - 3); processDefinitionName = str + "(" + num + ")"; } else { processDefinitionName = processDefinition.getName() + "(" + num + ")"; } } else { return processDefinitionName; } return recursionProcessDefinitionName(projectCode, processDefinitionName, num + 1); } /** * check the process task relation json * * @param processTaskRelationJson process task relation json * @return check result code */ @Override public Map<String, Object> checkProcessNodeList(String processTaskRelationJson) { Map<String, Object> result = new HashMap<>(); try { if (processTaskRelationJson == null) { logger.error("process data is null");
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,320
[Bug] [API] batch delete process definition bug
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened batch delete process definition fail ### What you expected to happen batch delete process definition success ### How to reproduce batch delete process definition ### Anything else _No response_ ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6320
https://github.com/apache/dolphinscheduler/pull/6321
c4375a54c167f8e96d80c3cc67ad0a607ba2ef7b
99f593cf42d6abd4312c74511f60ac8a2eeafb25
2021-09-23T12:44:06Z
java
2021-09-23T14:43:15Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java
putMsg(result, Status.DATA_IS_NOT_VALID, processTaskRelationJson); return result; } List<ProcessTaskRelation> taskRelationList = JSONUtils.toList(processTaskRelationJson, ProcessTaskRelation.class); List<TaskNode> taskNodes = processService.transformTask(taskRelationList, Lists.newArrayList()); if (CollectionUtils.isEmpty(taskNodes)) { logger.error("process node info is empty"); putMsg(result, Status.PROCESS_DAG_IS_EMPTY); return result; } if (graphHasCycle(taskNodes)) { logger.error("process DAG has cycle"); putMsg(result, Status.PROCESS_NODE_HAS_CYCLE); return result; } for (TaskNode taskNode : taskNodes) { if (!CheckUtils.checkTaskNodeParameters(taskNode)) { logger.error("task node {} parameter invalid", taskNode.getName()); putMsg(result, Status.PROCESS_NODE_S_PARAMETER_INVALID, taskNode.getName()); return result; } CheckUtils.checkOtherParams(taskNode.getExtras()); } putMsg(result, Status.SUCCESS); } catch (Exception e) { result.put(Constants.STATUS, Status.REQUEST_PARAMS_NOT_VALID_ERROR);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,320
[Bug] [API] batch delete process definition bug
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened batch delete process definition fail ### What you expected to happen batch delete process definition success ### How to reproduce batch delete process definition ### Anything else _No response_ ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6320
https://github.com/apache/dolphinscheduler/pull/6321
c4375a54c167f8e96d80c3cc67ad0a607ba2ef7b
99f593cf42d6abd4312c74511f60ac8a2eeafb25
2021-09-23T12:44:06Z
java
2021-09-23T14:43:15Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java
result.put(Constants.MSG, e.getMessage()); } return result; } /** * get task node details based on process definition * * @param loginUser loginUser * @param projectCode project code * @param code process definition code * @return task node list */ @Override public Map<String, Object> getTaskNodeListByDefinitionCode(User loginUser, long projectCode, long code) { Project project = projectMapper.queryByCode(projectCode); Map<String, Object> result = projectService.checkProjectAndAuth(loginUser, project, projectCode); if (result.get(Constants.STATUS) != Status.SUCCESS) { return result; } ProcessDefinition processDefinition = processDefinitionMapper.queryByCode(code); if (processDefinition == null) { logger.info("process define not exists"); putMsg(result, Status.PROCESS_DEFINE_NOT_EXIST, code); return result; } DagData dagData = processService.genDagData(processDefinition); result.put(Constants.DATA_LIST, dagData.getTaskDefinitionList()); putMsg(result, Status.SUCCESS); return result;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,320
[Bug] [API] batch delete process definition bug
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened batch delete process definition fail ### What you expected to happen batch delete process definition success ### How to reproduce batch delete process definition ### Anything else _No response_ ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6320
https://github.com/apache/dolphinscheduler/pull/6321
c4375a54c167f8e96d80c3cc67ad0a607ba2ef7b
99f593cf42d6abd4312c74511f60ac8a2eeafb25
2021-09-23T12:44:06Z
java
2021-09-23T14:43:15Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java
} /** * get task node details map based on process definition * * @param loginUser loginUser * @param projectCode project code * @param codes define codes * @return task node list */ @Override public Map<String, Object> getNodeListMapByDefinitionCodes(User loginUser, long projectCode, String codes) { Project project = projectMapper.queryByCode(projectCode); Map<String, Object> result = projectService.checkProjectAndAuth(loginUser, project, projectCode); if (result.get(Constants.STATUS) != Status.SUCCESS) { return result; } Set<Long> defineCodeSet = Lists.newArrayList(codes.split(Constants.COMMA)).stream().map(Long::parseLong).collect(Collectors.toSet()); List<ProcessDefinition> processDefinitionList = processDefinitionMapper.queryByCodes(defineCodeSet); if (CollectionUtils.isEmpty(processDefinitionList)) { logger.info("process definition not exists"); putMsg(result, Status.PROCESS_DEFINE_NOT_EXIST, codes); return result; } Map<Long, List<TaskDefinition>> taskNodeMap = new HashMap<>(); for (ProcessDefinition processDefinition : processDefinitionList) { DagData dagData = processService.genDagData(processDefinition); taskNodeMap.put(processDefinition.getCode(), dagData.getTaskDefinitionList()); } result.put(Constants.DATA_LIST, taskNodeMap);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,320
[Bug] [API] batch delete process definition bug
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened batch delete process definition fail ### What you expected to happen batch delete process definition success ### How to reproduce batch delete process definition ### Anything else _No response_ ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6320
https://github.com/apache/dolphinscheduler/pull/6321
c4375a54c167f8e96d80c3cc67ad0a607ba2ef7b
99f593cf42d6abd4312c74511f60ac8a2eeafb25
2021-09-23T12:44:06Z
java
2021-09-23T14:43:15Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java
putMsg(result, Status.SUCCESS); return result; } /** * query process definition all by project code * * @param loginUser loginUser * @param projectCode project code * @return process definitions in the project */ @Override public Map<String, Object> queryAllProcessDefinitionByProjectCode(User loginUser, long projectCode) { Project project = projectMapper.queryByCode(projectCode); Map<String, Object> result = projectService.checkProjectAndAuth(loginUser, project, projectCode); if (result.get(Constants.STATUS) != Status.SUCCESS) { return result; } List<ProcessDefinition> processDefinitions = processDefinitionMapper.queryAllDefinitionList(projectCode); List<DagData> dagDataList = processDefinitions.stream().map(processService::genDagData).collect(Collectors.toList()); result.put(Constants.DATA_LIST, dagDataList); putMsg(result, Status.SUCCESS); return result; } /** * Encapsulates the TreeView structure * * @param code process definition code * @param limit limit * @return tree view json data
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,320
[Bug] [API] batch delete process definition bug
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened batch delete process definition fail ### What you expected to happen batch delete process definition success ### How to reproduce batch delete process definition ### Anything else _No response_ ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6320
https://github.com/apache/dolphinscheduler/pull/6321
c4375a54c167f8e96d80c3cc67ad0a607ba2ef7b
99f593cf42d6abd4312c74511f60ac8a2eeafb25
2021-09-23T12:44:06Z
java
2021-09-23T14:43:15Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java
*/ @Override public Map<String, Object> viewTree(long code, Integer limit) { Map<String, Object> result = new HashMap<>(); ProcessDefinition processDefinition = processDefinitionMapper.queryByCode(code); if (null == processDefinition) { logger.info("process define not exists"); putMsg(result, Status.PROCESS_DEFINE_NOT_EXIST, code); return result; } DAG<String, TaskNode, TaskNodeRelation> dag = processService.genDagGraph(processDefinition); Map<String, List<TreeViewDto>> runningNodeMap = new ConcurrentHashMap<>(); Map<String, List<TreeViewDto>> waitingRunningNodeMap = new ConcurrentHashMap<>(); List<ProcessInstance> processInstanceList = processInstanceService.queryByProcessDefineCode(code, limit); processInstanceList.forEach(processInstance -> processInstance.setDuration(DateUtils.format2Duration(processInstance.getStartTime(), processInstance.getEndTime()))); List<TaskDefinitionLog> taskDefinitionList = processService.genTaskDefineList(processTaskRelationMapper.queryByProcessCode(processDefinition.getProjectCode(), processDefinition.getCode())); Map<Long, TaskDefinitionLog> taskDefinitionMap = taskDefinitionList.stream() .collect(Collectors.toMap(TaskDefinitionLog::getCode, taskDefinitionLog -> taskDefinitionLog)); if (limit > processInstanceList.size()) { limit = processInstanceList.size(); } TreeViewDto parentTreeViewDto = new TreeViewDto(); parentTreeViewDto.setName("DAG"); parentTreeViewDto.setType(""); parentTreeViewDto.setCode(0L); for (int i = limit - 1; i >= 0; i--) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,320
[Bug] [API] batch delete process definition bug
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened batch delete process definition fail ### What you expected to happen batch delete process definition success ### How to reproduce batch delete process definition ### Anything else _No response_ ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6320
https://github.com/apache/dolphinscheduler/pull/6321
c4375a54c167f8e96d80c3cc67ad0a607ba2ef7b
99f593cf42d6abd4312c74511f60ac8a2eeafb25
2021-09-23T12:44:06Z
java
2021-09-23T14:43:15Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java
ProcessInstance processInstance = processInstanceList.get(i); Date endTime = processInstance.getEndTime() == null ? new Date() : processInstance.getEndTime(); parentTreeViewDto.getInstances().add(new Instance(processInstance.getId(), processInstance.getName(), processInstance.getProcessDefinitionCode(), "", processInstance.getState().toString(), processInstance.getStartTime(), endTime, processInstance.getHost(), DateUtils.format2Readable(endTime.getTime() - processInstance.getStartTime().getTime()))); } List<TreeViewDto> parentTreeViewDtoList = new ArrayList<>(); parentTreeViewDtoList.add(parentTreeViewDto); for (String startNode : dag.getBeginNode()) { runningNodeMap.put(startNode, parentTreeViewDtoList); } while (Stopper.isRunning()) { Set<String> postNodeList; Iterator<Map.Entry<String, List<TreeViewDto>>> iter = runningNodeMap.entrySet().iterator(); while (iter.hasNext()) { Map.Entry<String, List<TreeViewDto>> en = iter.next(); String nodeName = en.getKey(); parentTreeViewDtoList = en.getValue(); TreeViewDto treeViewDto = new TreeViewDto(); treeViewDto.setName(nodeName); TaskNode taskNode = dag.getNode(nodeName); treeViewDto.setType(taskNode.getType()); treeViewDto.setCode(taskNode.getCode()); for (int i = limit - 1; i >= 0; i--) { ProcessInstance processInstance = processInstanceList.get(i); TaskInstance taskInstance = taskInstanceMapper.queryByInstanceIdAndName(processInstance.getId(), nodeName); if (taskInstance == null) { treeViewDto.getInstances().add(new Instance(-1, "not running", 0, "null"));
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,320
[Bug] [API] batch delete process definition bug
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened batch delete process definition fail ### What you expected to happen batch delete process definition success ### How to reproduce batch delete process definition ### Anything else _No response_ ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6320
https://github.com/apache/dolphinscheduler/pull/6321
c4375a54c167f8e96d80c3cc67ad0a607ba2ef7b
99f593cf42d6abd4312c74511f60ac8a2eeafb25
2021-09-23T12:44:06Z
java
2021-09-23T14:43:15Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java
} else { Date startTime = taskInstance.getStartTime() == null ? new Date() : taskInstance.getStartTime(); Date endTime = taskInstance.getEndTime() == null ? new Date() : taskInstance.getEndTime(); int subProcessId = 0; if (taskInstance.isSubProcess()) { TaskDefinition taskDefinition = taskDefinitionMap.get(taskInstance.getTaskCode()); subProcessId = Integer.parseInt(JSONUtils.parseObject( taskDefinition.getTaskParams()).path(CMD_PARAM_SUB_PROCESS_DEFINE_ID).asText()); } treeViewDto.getInstances().add(new Instance(taskInstance.getId(), taskInstance.getName(), taskInstance.getTaskCode(), taskInstance.getTaskType(), taskInstance.getState().toString(), taskInstance.getStartTime(), taskInstance.getEndTime(), taskInstance.getHost(), DateUtils.format2Readable(endTime.getTime() - startTime.getTime()), subProcessId)); } } for (TreeViewDto pTreeViewDto : parentTreeViewDtoList) { pTreeViewDto.getChildren().add(treeViewDto); } postNodeList = dag.getSubsequentNodes(nodeName); if (CollectionUtils.isNotEmpty(postNodeList)) { for (String nextNodeName : postNodeList) { List<TreeViewDto> treeViewDtoList = waitingRunningNodeMap.get(nextNodeName); if (CollectionUtils.isEmpty(treeViewDtoList)) { treeViewDtoList = new ArrayList<>(); } treeViewDtoList.add(treeViewDto); waitingRunningNodeMap.put(nextNodeName, treeViewDtoList); } } runningNodeMap.remove(nodeName);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,320
[Bug] [API] batch delete process definition bug
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened batch delete process definition fail ### What you expected to happen batch delete process definition success ### How to reproduce batch delete process definition ### Anything else _No response_ ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6320
https://github.com/apache/dolphinscheduler/pull/6321
c4375a54c167f8e96d80c3cc67ad0a607ba2ef7b
99f593cf42d6abd4312c74511f60ac8a2eeafb25
2021-09-23T12:44:06Z
java
2021-09-23T14:43:15Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java
} if (waitingRunningNodeMap.size() == 0) { break; } else { runningNodeMap.putAll(waitingRunningNodeMap); waitingRunningNodeMap.clear(); } } result.put(Constants.DATA_LIST, parentTreeViewDto); result.put(Constants.STATUS, Status.SUCCESS); result.put(Constants.MSG, Status.SUCCESS.getMsg()); return result; } /** * whether the graph has a ring * * @param taskNodeResponseList task node response list * @return if graph has cycle flag */ private boolean graphHasCycle(List<TaskNode> taskNodeResponseList) { DAG<String, TaskNode, String> graph = new DAG<>(); for (TaskNode taskNodeResponse : taskNodeResponseList) { graph.addNode(taskNodeResponse.getName(), taskNodeResponse); } for (TaskNode taskNodeResponse : taskNodeResponseList) { List<String> preTasks = JSONUtils.toList(taskNodeResponse.getPreTasks(), String.class); if (CollectionUtils.isNotEmpty(preTasks)) { for (String preTask : preTasks) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,320
[Bug] [API] batch delete process definition bug
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened batch delete process definition fail ### What you expected to happen batch delete process definition success ### How to reproduce batch delete process definition ### Anything else _No response_ ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6320
https://github.com/apache/dolphinscheduler/pull/6321
c4375a54c167f8e96d80c3cc67ad0a607ba2ef7b
99f593cf42d6abd4312c74511f60ac8a2eeafb25
2021-09-23T12:44:06Z
java
2021-09-23T14:43:15Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java
if (!graph.addEdge(preTask, taskNodeResponse.getName())) { return true; } } } } return graph.hasCycle(); } /** * batch copy process definition * * @param loginUser loginUser * @param projectCode projectCode * @param codes processDefinitionCodes * @param targetProjectCode targetProjectCode */ @Override public Map<String, Object> batchCopyProcessDefinition(User loginUser, long projectCode, String codes, long targetProjectCode) { Map<String, Object> result = checkParams(loginUser, projectCode, codes, targetProjectCode); if (result.get(Constants.STATUS) != Status.SUCCESS) { return result; } List<String> failedProcessList = new ArrayList<>(); doBatchOperateProcessDefinition(loginUser, targetProjectCode, failedProcessList, codes, result, true); checkBatchOperateResult(projectCode, targetProjectCode, result, failedProcessList, true); return result; }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,320
[Bug] [API] batch delete process definition bug
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened batch delete process definition fail ### What you expected to happen batch delete process definition success ### How to reproduce batch delete process definition ### Anything else _No response_ ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6320
https://github.com/apache/dolphinscheduler/pull/6321
c4375a54c167f8e96d80c3cc67ad0a607ba2ef7b
99f593cf42d6abd4312c74511f60ac8a2eeafb25
2021-09-23T12:44:06Z
java
2021-09-23T14:43:15Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java
/** * batch move process definition * * @param loginUser loginUser * @param projectCode projectCode * @param codes processDefinitionCodes * @param targetProjectCode targetProjectCode */ @Override @Transactional(rollbackFor = RuntimeException.class) public Map<String, Object> batchMoveProcessDefinition(User loginUser, long projectCode, String codes, long targetProjectCode) { Map<String, Object> result = checkParams(loginUser, projectCode, codes, targetProjectCode); if (result.get(Constants.STATUS) != Status.SUCCESS) { return result; } if (projectCode == targetProjectCode) { return result; } List<String> failedProcessList = new ArrayList<>(); doBatchOperateProcessDefinition(loginUser, targetProjectCode, failedProcessList, codes, result, false); checkBatchOperateResult(projectCode, targetProjectCode, result, failedProcessList, false); return result; } private Map<String, Object> checkParams(User loginUser, long projectCode, String processDefinitionCodes, long targetProjectCode) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,320
[Bug] [API] batch delete process definition bug
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened batch delete process definition fail ### What you expected to happen batch delete process definition success ### How to reproduce batch delete process definition ### Anything else _No response_ ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6320
https://github.com/apache/dolphinscheduler/pull/6321
c4375a54c167f8e96d80c3cc67ad0a607ba2ef7b
99f593cf42d6abd4312c74511f60ac8a2eeafb25
2021-09-23T12:44:06Z
java
2021-09-23T14:43:15Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java
Project project = projectMapper.queryByCode(projectCode); Map<String, Object> result = projectService.checkProjectAndAuth(loginUser, project, projectCode); if (result.get(Constants.STATUS) != Status.SUCCESS) { return result; } if (StringUtils.isEmpty(processDefinitionCodes)) { putMsg(result, Status.PROCESS_DEFINITION_CODES_IS_EMPTY, processDefinitionCodes); return result; } if (projectCode != targetProjectCode) { Project targetProject = projectMapper.queryByCode(targetProjectCode); Map<String, Object> targetResult = projectService.checkProjectAndAuth(loginUser, targetProject, targetProjectCode); if (targetResult.get(Constants.STATUS) != Status.SUCCESS) { return targetResult; } } return result; } private void doBatchOperateProcessDefinition(User loginUser, long targetProjectCode, List<String> failedProcessList, String processDefinitionCodes, Map<String, Object> result, boolean isCopy) { Set<Long> definitionCodes = Arrays.stream(processDefinitionCodes.split(Constants.COMMA)).map(Long::parseLong).collect(Collectors.toSet()); List<ProcessDefinition> processDefinitionList = processDefinitionMapper.queryByCodes(definitionCodes); Set<Long> queryCodes = processDefinitionList.stream().map(ProcessDefinition::getCode).collect(Collectors.toSet());
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,320
[Bug] [API] batch delete process definition bug
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened batch delete process definition fail ### What you expected to happen batch delete process definition success ### How to reproduce batch delete process definition ### Anything else _No response_ ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6320
https://github.com/apache/dolphinscheduler/pull/6321
c4375a54c167f8e96d80c3cc67ad0a607ba2ef7b
99f593cf42d6abd4312c74511f60ac8a2eeafb25
2021-09-23T12:44:06Z
java
2021-09-23T14:43:15Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java
Set<Long> diffCode = definitionCodes.stream().filter(code -> !queryCodes.contains(code)).collect(Collectors.toSet()); diffCode.forEach(code -> failedProcessList.add(code + "[null]")); for (ProcessDefinition processDefinition : processDefinitionList) { List<ProcessTaskRelation> processTaskRelations = processTaskRelationMapper.queryByProcessCode(processDefinition.getProjectCode(), processDefinition.getCode()); List<ProcessTaskRelationLog> taskRelationList = processTaskRelations.stream().map(ProcessTaskRelationLog::new).collect(Collectors.toList()); processDefinition.setProjectCode(targetProjectCode); if (isCopy) { processDefinition.setName(processDefinition.getName() + "_copy_" + DateUtils.getCurrentTimeStamp()); try { result.putAll(createDagDefine(loginUser, taskRelationList, processDefinition, Lists.newArrayList())); } catch (Exception e) { putMsg(result, Status.COPY_PROCESS_DEFINITION_ERROR); throw new ServiceException(Status.COPY_PROCESS_DEFINITION_ERROR); } } else { try { result.putAll(updateDagDefine(loginUser, taskRelationList, processDefinition, null, Lists.newArrayList())); } catch (Exception e) { putMsg(result, Status.MOVE_PROCESS_DEFINITION_ERROR); throw new ServiceException(Status.MOVE_PROCESS_DEFINITION_ERROR); } } if (result.get(Constants.STATUS) != Status.SUCCESS) { failedProcessList.add(processDefinition.getCode() + "[" + processDefinition.getName() + "]"); } } } /** * switch the defined process definition version
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,320
[Bug] [API] batch delete process definition bug
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened batch delete process definition fail ### What you expected to happen batch delete process definition success ### How to reproduce batch delete process definition ### Anything else _No response_ ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6320
https://github.com/apache/dolphinscheduler/pull/6321
c4375a54c167f8e96d80c3cc67ad0a607ba2ef7b
99f593cf42d6abd4312c74511f60ac8a2eeafb25
2021-09-23T12:44:06Z
java
2021-09-23T14:43:15Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java
* * @param loginUser login user * @param projectCode project code * @param code process definition code * @param version the version user want to switch * @return switch process definition version result code */ @Override @Transactional(rollbackFor = RuntimeException.class) public Map<String, Object> switchProcessDefinitionVersion(User loginUser, long projectCode, long code, int version) { Project project = projectMapper.queryByCode(projectCode); Map<String, Object> result = projectService.checkProjectAndAuth(loginUser, project, projectCode); if (result.get(Constants.STATUS) != Status.SUCCESS) { return result; } ProcessDefinition processDefinition = processDefinitionMapper.queryByCode(code); if (Objects.isNull(processDefinition)) { putMsg(result, Status.SWITCH_PROCESS_DEFINITION_VERSION_NOT_EXIST_PROCESS_DEFINITION_ERROR, code); return result; } ProcessDefinitionLog processDefinitionLog = processDefinitionLogMapper.queryByDefinitionCodeAndVersion(code, version); if (Objects.isNull(processDefinitionLog)) { putMsg(result, Status.SWITCH_PROCESS_DEFINITION_VERSION_NOT_EXIST_PROCESS_DEFINITION_VERSION_ERROR, processDefinition.getCode(), version); return result; } int switchVersion = processService.switchVersion(processDefinition, processDefinitionLog); if (switchVersion > 0) { putMsg(result, Status.SWITCH_PROCESS_DEFINITION_VERSION_ERROR); throw new ServiceException(Status.SWITCH_PROCESS_DEFINITION_VERSION_ERROR);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,320
[Bug] [API] batch delete process definition bug
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened batch delete process definition fail ### What you expected to happen batch delete process definition success ### How to reproduce batch delete process definition ### Anything else _No response_ ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6320
https://github.com/apache/dolphinscheduler/pull/6321
c4375a54c167f8e96d80c3cc67ad0a607ba2ef7b
99f593cf42d6abd4312c74511f60ac8a2eeafb25
2021-09-23T12:44:06Z
java
2021-09-23T14:43:15Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java
} putMsg(result, Status.SUCCESS); return result; } /** * check batch operate result * * @param srcProjectCode srcProjectCode * @param targetProjectCode targetProjectCode * @param result result * @param failedProcessList failedProcessList * @param isCopy isCopy */ private void checkBatchOperateResult(long srcProjectCode, long targetProjectCode, Map<String, Object> result, List<String> failedProcessList, boolean isCopy) { if (!failedProcessList.isEmpty()) { if (isCopy) { putMsg(result, Status.COPY_PROCESS_DEFINITION_ERROR, srcProjectCode, targetProjectCode, String.join(",", failedProcessList)); } else { putMsg(result, Status.MOVE_PROCESS_DEFINITION_ERROR, srcProjectCode, targetProjectCode, String.join(",", failedProcessList)); } } else { putMsg(result, Status.SUCCESS); } } /** * query the pagination versions info by one certain process definition code * * @param loginUser login user info to check auth * @param projectCode project code
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,320
[Bug] [API] batch delete process definition bug
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened batch delete process definition fail ### What you expected to happen batch delete process definition success ### How to reproduce batch delete process definition ### Anything else _No response_ ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6320
https://github.com/apache/dolphinscheduler/pull/6321
c4375a54c167f8e96d80c3cc67ad0a607ba2ef7b
99f593cf42d6abd4312c74511f60ac8a2eeafb25
2021-09-23T12:44:06Z
java
2021-09-23T14:43:15Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java
* @param pageNo page number * @param pageSize page size * @param code process definition code * @return the pagination process definition versions info of the certain process definition */ @Override public Result queryProcessDefinitionVersions(User loginUser, long projectCode, int pageNo, int pageSize, long code) { Result result = new Result(); Project project = projectMapper.queryByCode(projectCode); Map<String, Object> checkResult = projectService.checkProjectAndAuth(loginUser, project, projectCode); Status resultStatus = (Status) checkResult.get(Constants.STATUS); if (resultStatus != Status.SUCCESS) { putMsg(result, resultStatus); return result; } PageInfo<ProcessDefinitionLog> pageInfo = new PageInfo<>(pageNo, pageSize); Page<ProcessDefinitionLog> page = new Page<>(pageNo, pageSize); IPage<ProcessDefinitionLog> processDefinitionVersionsPaging = processDefinitionLogMapper.queryProcessDefinitionVersionsPaging(page, code); List<ProcessDefinitionLog> processDefinitionLogs = processDefinitionVersionsPaging.getRecords(); pageInfo.setTotalList(processDefinitionLogs); pageInfo.setTotal((int) processDefinitionVersionsPaging.getTotal()); result.setData(pageInfo); putMsg(result, Status.SUCCESS); return result; } /** * delete one certain process definition by version number and process definition code * * @param loginUser login user info to check auth
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,320
[Bug] [API] batch delete process definition bug
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened batch delete process definition fail ### What you expected to happen batch delete process definition success ### How to reproduce batch delete process definition ### Anything else _No response_ ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6320
https://github.com/apache/dolphinscheduler/pull/6321
c4375a54c167f8e96d80c3cc67ad0a607ba2ef7b
99f593cf42d6abd4312c74511f60ac8a2eeafb25
2021-09-23T12:44:06Z
java
2021-09-23T14:43:15Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java
* @param projectCode project code * @param code process definition code * @param version version number * @return delete result code */ @Override @Transactional(rollbackFor = RuntimeException.class) public Map<String, Object> deleteProcessDefinitionVersion(User loginUser, long projectCode, long code, int version) { Project project = projectMapper.queryByCode(projectCode); Map<String, Object> result = projectService.checkProjectAndAuth(loginUser, project, projectCode); if (result.get(Constants.STATUS) != Status.SUCCESS) { return result; } ProcessDefinition processDefinition = processDefinitionMapper.queryByCode(code); if (processDefinition == null) { putMsg(result, Status.PROCESS_DEFINE_NOT_EXIST, code); } else { int deleteLog = processDefinitionLogMapper.deleteByProcessDefinitionCodeAndVersion(code, version); int deleteRelationLog = processTaskRelationLogMapper.deleteByCode(processDefinition.getCode(), processDefinition.getVersion()); if ((deleteLog & deleteRelationLog) == 0) { putMsg(result, Status.DELETE_PROCESS_DEFINE_BY_CODE_ERROR); throw new ServiceException(Status.DELETE_PROCESS_DEFINE_BY_CODE_ERROR); } putMsg(result, Status.SUCCESS); } return result; } }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,072
[Bug][common] Generics type is invalid in JsonUtils.toMap
**Describe the bug** This method is hope to deserialize a JSON to Map. https://github.com/apache/dolphinscheduler/blob/e866d1be86464d812551e8c38ba60767a204c82e/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/JSONUtils.java#L249-L251 But the generics type in the Map is not what we expected. We can write a simple test case: ```java String sqlResult = "{\"id\":[],\"test1\":\"6\"}"; Map<String, List> param = toMap(sqlResult, String.class, List.class); System.out.println(param); ``` It will execute success, and print ``` {id=[], test1=6} ``` The value type of `id` is `List`, the value type of `test1` is `String`. But If we loop the map, it will throw a exception, because the value in this map has different type ```java String sqlResult = "{\"id\":[],\"test1\":\"6\"}"; Map<String, List> param = toMap(sqlResult, String.class, List.class); param.forEach((key, value) -> System.out.println(value)); ``` ``` [] Exception in thread "main" java.lang.ClassCastException: java.lang.String cannot be cast to java.util.List at java.util.LinkedHashMap.forEach(LinkedHashMap.java:684) at org.apache.dolphinscheduler.common.utils.JSONUtils.main(JSONUtils.java:256) ``` I don't find out the deep reason, but I think we should remove this method. **Which version of Dolphin Scheduler:** -[dev]
https://github.com/apache/dolphinscheduler/issues/6072
https://github.com/apache/dolphinscheduler/pull/6283
c855a5926ceb9cfb6efb0c901c8d92fe3774e999
46257834792d3316c9f5ef885f38e069e4eb6452
2021-08-31T10:30:15Z
java
2021-09-23T15:06:53Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
/* * 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. */
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,072
[Bug][common] Generics type is invalid in JsonUtils.toMap
**Describe the bug** This method is hope to deserialize a JSON to Map. https://github.com/apache/dolphinscheduler/blob/e866d1be86464d812551e8c38ba60767a204c82e/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/JSONUtils.java#L249-L251 But the generics type in the Map is not what we expected. We can write a simple test case: ```java String sqlResult = "{\"id\":[],\"test1\":\"6\"}"; Map<String, List> param = toMap(sqlResult, String.class, List.class); System.out.println(param); ``` It will execute success, and print ``` {id=[], test1=6} ``` The value type of `id` is `List`, the value type of `test1` is `String`. But If we loop the map, it will throw a exception, because the value in this map has different type ```java String sqlResult = "{\"id\":[],\"test1\":\"6\"}"; Map<String, List> param = toMap(sqlResult, String.class, List.class); param.forEach((key, value) -> System.out.println(value)); ``` ``` [] Exception in thread "main" java.lang.ClassCastException: java.lang.String cannot be cast to java.util.List at java.util.LinkedHashMap.forEach(LinkedHashMap.java:684) at org.apache.dolphinscheduler.common.utils.JSONUtils.main(JSONUtils.java:256) ``` I don't find out the deep reason, but I think we should remove this method. **Which version of Dolphin Scheduler:** -[dev]
https://github.com/apache/dolphinscheduler/issues/6072
https://github.com/apache/dolphinscheduler/pull/6283
c855a5926ceb9cfb6efb0c901c8d92fe3774e999
46257834792d3316c9f5ef885f38e069e4eb6452
2021-08-31T10:30:15Z
java
2021-09-23T15:06:53Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
package org.apache.dolphinscheduler.api.service.impl; import static org.apache.dolphinscheduler.common.Constants.CMDPARAM_COMPLEMENT_DATA_END_DATE; import static org.apache.dolphinscheduler.common.Constants.CMDPARAM_COMPLEMENT_DATA_START_DATE; import static org.apache.dolphinscheduler.common.Constants.CMD_PARAM_RECOVER_PROCESS_ID_STRING; import static org.apache.dolphinscheduler.common.Constants.CMD_PARAM_START_NODE_NAMES; import static org.apache.dolphinscheduler.common.Constants.CMD_PARAM_START_PARAMS; import static org.apache.dolphinscheduler.common.Constants.MAX_TASK_TIMEOUT; import org.apache.dolphinscheduler.api.enums.ExecuteType; import org.apache.dolphinscheduler.api.enums.Status; import org.apache.dolphinscheduler.api.service.ExecutorService; import org.apache.dolphinscheduler.api.service.MonitorService; import org.apache.dolphinscheduler.api.service.ProjectService; import org.apache.dolphinscheduler.common.Constants; import org.apache.dolphinscheduler.common.enums.CommandType; import org.apache.dolphinscheduler.common.enums.ExecutionStatus; import org.apache.dolphinscheduler.common.enums.FailureStrategy; import org.apache.dolphinscheduler.common.enums.Priority; import org.apache.dolphinscheduler.common.enums.ReleaseState; import org.apache.dolphinscheduler.common.enums.RunMode; import org.apache.dolphinscheduler.common.enums.TaskDependType; import org.apache.dolphinscheduler.common.enums.WarningType; import org.apache.dolphinscheduler.common.model.Server; import org.apache.dolphinscheduler.common.utils.CollectionUtils; import org.apache.dolphinscheduler.common.utils.DateUtils; import org.apache.dolphinscheduler.common.utils.JSONUtils; import org.apache.dolphinscheduler.dao.entity.Command; import org.apache.dolphinscheduler.dao.entity.ProcessDefinition; import org.apache.dolphinscheduler.dao.entity.ProcessInstance; import org.apache.dolphinscheduler.dao.entity.Project; import org.apache.dolphinscheduler.dao.entity.Schedule;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,072
[Bug][common] Generics type is invalid in JsonUtils.toMap
**Describe the bug** This method is hope to deserialize a JSON to Map. https://github.com/apache/dolphinscheduler/blob/e866d1be86464d812551e8c38ba60767a204c82e/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/JSONUtils.java#L249-L251 But the generics type in the Map is not what we expected. We can write a simple test case: ```java String sqlResult = "{\"id\":[],\"test1\":\"6\"}"; Map<String, List> param = toMap(sqlResult, String.class, List.class); System.out.println(param); ``` It will execute success, and print ``` {id=[], test1=6} ``` The value type of `id` is `List`, the value type of `test1` is `String`. But If we loop the map, it will throw a exception, because the value in this map has different type ```java String sqlResult = "{\"id\":[],\"test1\":\"6\"}"; Map<String, List> param = toMap(sqlResult, String.class, List.class); param.forEach((key, value) -> System.out.println(value)); ``` ``` [] Exception in thread "main" java.lang.ClassCastException: java.lang.String cannot be cast to java.util.List at java.util.LinkedHashMap.forEach(LinkedHashMap.java:684) at org.apache.dolphinscheduler.common.utils.JSONUtils.main(JSONUtils.java:256) ``` I don't find out the deep reason, but I think we should remove this method. **Which version of Dolphin Scheduler:** -[dev]
https://github.com/apache/dolphinscheduler/issues/6072
https://github.com/apache/dolphinscheduler/pull/6283
c855a5926ceb9cfb6efb0c901c8d92fe3774e999
46257834792d3316c9f5ef885f38e069e4eb6452
2021-08-31T10:30:15Z
java
2021-09-23T15:06:53Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
import org.apache.dolphinscheduler.dao.entity.Tenant; import org.apache.dolphinscheduler.dao.entity.User; import org.apache.dolphinscheduler.dao.mapper.ProcessDefinitionMapper; import org.apache.dolphinscheduler.dao.mapper.ProcessInstanceMapper; import org.apache.dolphinscheduler.dao.mapper.ProjectMapper; import org.apache.dolphinscheduler.remote.command.StateEventChangeCommand; import org.apache.dolphinscheduler.remote.processor.StateEventCallbackService; import org.apache.dolphinscheduler.service.process.ProcessService; import org.apache.dolphinscheduler.service.quartz.cron.CronUtils; import org.apache.commons.collections.MapUtils; import org.apache.commons.lang.StringUtils; import java.util.ArrayList; import java.util.Date; import java.util.HashMap; import java.util.LinkedList; import java.util.List; import java.util.Map; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; /** * executor service impl */ @Service public class ExecutorServiceImpl extends BaseServiceImpl implements ExecutorService { private static final Logger logger = LoggerFactory.getLogger(ExecutorServiceImpl.class); @Autowired private ProjectMapper projectMapper; @Autowired
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,072
[Bug][common] Generics type is invalid in JsonUtils.toMap
**Describe the bug** This method is hope to deserialize a JSON to Map. https://github.com/apache/dolphinscheduler/blob/e866d1be86464d812551e8c38ba60767a204c82e/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/JSONUtils.java#L249-L251 But the generics type in the Map is not what we expected. We can write a simple test case: ```java String sqlResult = "{\"id\":[],\"test1\":\"6\"}"; Map<String, List> param = toMap(sqlResult, String.class, List.class); System.out.println(param); ``` It will execute success, and print ``` {id=[], test1=6} ``` The value type of `id` is `List`, the value type of `test1` is `String`. But If we loop the map, it will throw a exception, because the value in this map has different type ```java String sqlResult = "{\"id\":[],\"test1\":\"6\"}"; Map<String, List> param = toMap(sqlResult, String.class, List.class); param.forEach((key, value) -> System.out.println(value)); ``` ``` [] Exception in thread "main" java.lang.ClassCastException: java.lang.String cannot be cast to java.util.List at java.util.LinkedHashMap.forEach(LinkedHashMap.java:684) at org.apache.dolphinscheduler.common.utils.JSONUtils.main(JSONUtils.java:256) ``` I don't find out the deep reason, but I think we should remove this method. **Which version of Dolphin Scheduler:** -[dev]
https://github.com/apache/dolphinscheduler/issues/6072
https://github.com/apache/dolphinscheduler/pull/6283
c855a5926ceb9cfb6efb0c901c8d92fe3774e999
46257834792d3316c9f5ef885f38e069e4eb6452
2021-08-31T10:30:15Z
java
2021-09-23T15:06:53Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
private ProjectService projectService; @Autowired private ProcessDefinitionMapper processDefinitionMapper; @Autowired private MonitorService monitorService; @Autowired private ProcessInstanceMapper processInstanceMapper; @Autowired private ProcessService processService; @Autowired StateEventCallbackService stateEventCallbackService; /** * execute process instance * * @param loginUser login user * @param projectCode project code * @param processDefinitionCode process definition code * @param cronTime cron time * @param commandType command type * @param failureStrategy failure strategy * @param startNodeList start nodelist * @param taskDependType node dependency type * @param warningType warning type * @param warningGroupId notify group id * @param processInstancePriority process instance priority * @param workerGroup worker group name * @param environmentCode environment code * @param runMode run mode * @param timeout timeout * @param startParams the global param values which pass to new process instance
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,072
[Bug][common] Generics type is invalid in JsonUtils.toMap
**Describe the bug** This method is hope to deserialize a JSON to Map. https://github.com/apache/dolphinscheduler/blob/e866d1be86464d812551e8c38ba60767a204c82e/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/JSONUtils.java#L249-L251 But the generics type in the Map is not what we expected. We can write a simple test case: ```java String sqlResult = "{\"id\":[],\"test1\":\"6\"}"; Map<String, List> param = toMap(sqlResult, String.class, List.class); System.out.println(param); ``` It will execute success, and print ``` {id=[], test1=6} ``` The value type of `id` is `List`, the value type of `test1` is `String`. But If we loop the map, it will throw a exception, because the value in this map has different type ```java String sqlResult = "{\"id\":[],\"test1\":\"6\"}"; Map<String, List> param = toMap(sqlResult, String.class, List.class); param.forEach((key, value) -> System.out.println(value)); ``` ``` [] Exception in thread "main" java.lang.ClassCastException: java.lang.String cannot be cast to java.util.List at java.util.LinkedHashMap.forEach(LinkedHashMap.java:684) at org.apache.dolphinscheduler.common.utils.JSONUtils.main(JSONUtils.java:256) ``` I don't find out the deep reason, but I think we should remove this method. **Which version of Dolphin Scheduler:** -[dev]
https://github.com/apache/dolphinscheduler/issues/6072
https://github.com/apache/dolphinscheduler/pull/6283
c855a5926ceb9cfb6efb0c901c8d92fe3774e999
46257834792d3316c9f5ef885f38e069e4eb6452
2021-08-31T10:30:15Z
java
2021-09-23T15:06:53Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
* @param expectedParallelismNumber the expected parallelism number when execute complement in parallel mode * @return execute process instance code */ @Override public Map<String, Object> execProcessInstance(User loginUser, long projectCode, long processDefinitionCode, String cronTime, CommandType commandType, FailureStrategy failureStrategy, String startNodeList, TaskDependType taskDependType, WarningType warningType, int warningGroupId, RunMode runMode, Priority processInstancePriority, String workerGroup, Long environmentCode,Integer timeout, Map<String, String> startParams, Integer expectedParallelismNumber) { Project project = projectMapper.queryByCode(projectCode); Map<String, Object> result = projectService.checkProjectAndAuth(loginUser, project, projectCode); if (result.get(Constants.STATUS) != Status.SUCCESS) { return result; } if (timeout <= 0 || timeout > MAX_TASK_TIMEOUT) { putMsg(result, Status.TASK_TIMEOUT_PARAMS_ERROR); return result; } ProcessDefinition processDefinition = processDefinitionMapper.queryByCode(processDefinitionCode); result = checkProcessDefinitionValid(processDefinition, processDefinitionCode); if (result.get(Constants.STATUS) != Status.SUCCESS) { return result; } if (!checkTenantSuitable(processDefinition)) { logger.error("there is not any valid tenant for the process definition: id:{},name:{}, ",
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,072
[Bug][common] Generics type is invalid in JsonUtils.toMap
**Describe the bug** This method is hope to deserialize a JSON to Map. https://github.com/apache/dolphinscheduler/blob/e866d1be86464d812551e8c38ba60767a204c82e/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/JSONUtils.java#L249-L251 But the generics type in the Map is not what we expected. We can write a simple test case: ```java String sqlResult = "{\"id\":[],\"test1\":\"6\"}"; Map<String, List> param = toMap(sqlResult, String.class, List.class); System.out.println(param); ``` It will execute success, and print ``` {id=[], test1=6} ``` The value type of `id` is `List`, the value type of `test1` is `String`. But If we loop the map, it will throw a exception, because the value in this map has different type ```java String sqlResult = "{\"id\":[],\"test1\":\"6\"}"; Map<String, List> param = toMap(sqlResult, String.class, List.class); param.forEach((key, value) -> System.out.println(value)); ``` ``` [] Exception in thread "main" java.lang.ClassCastException: java.lang.String cannot be cast to java.util.List at java.util.LinkedHashMap.forEach(LinkedHashMap.java:684) at org.apache.dolphinscheduler.common.utils.JSONUtils.main(JSONUtils.java:256) ``` I don't find out the deep reason, but I think we should remove this method. **Which version of Dolphin Scheduler:** -[dev]
https://github.com/apache/dolphinscheduler/issues/6072
https://github.com/apache/dolphinscheduler/pull/6283
c855a5926ceb9cfb6efb0c901c8d92fe3774e999
46257834792d3316c9f5ef885f38e069e4eb6452
2021-08-31T10:30:15Z
java
2021-09-23T15:06:53Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
processDefinition.getId(), processDefinition.getName()); putMsg(result, Status.TENANT_NOT_SUITABLE); return result; } if (!checkMasterExists(result)) { return result; } /** * create command */ int create = this.createCommand(commandType, processDefinition.getCode(), taskDependType, failureStrategy, startNodeList, cronTime, warningType, loginUser.getId(), warningGroupId, runMode, processInstancePriority, workerGroup, environmentCode, startParams, expectedParallelismNumber); if (create > 0) { processDefinition.setWarningGroupId(warningGroupId); processDefinitionMapper.updateById(processDefinition); putMsg(result, Status.SUCCESS); } else { putMsg(result, Status.START_PROCESS_INSTANCE_ERROR); } return result; } /** * check whether master exists * * @param result result * @return master exists return true , otherwise return false */ private boolean checkMasterExists(Map<String, Object> result) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,072
[Bug][common] Generics type is invalid in JsonUtils.toMap
**Describe the bug** This method is hope to deserialize a JSON to Map. https://github.com/apache/dolphinscheduler/blob/e866d1be86464d812551e8c38ba60767a204c82e/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/JSONUtils.java#L249-L251 But the generics type in the Map is not what we expected. We can write a simple test case: ```java String sqlResult = "{\"id\":[],\"test1\":\"6\"}"; Map<String, List> param = toMap(sqlResult, String.class, List.class); System.out.println(param); ``` It will execute success, and print ``` {id=[], test1=6} ``` The value type of `id` is `List`, the value type of `test1` is `String`. But If we loop the map, it will throw a exception, because the value in this map has different type ```java String sqlResult = "{\"id\":[],\"test1\":\"6\"}"; Map<String, List> param = toMap(sqlResult, String.class, List.class); param.forEach((key, value) -> System.out.println(value)); ``` ``` [] Exception in thread "main" java.lang.ClassCastException: java.lang.String cannot be cast to java.util.List at java.util.LinkedHashMap.forEach(LinkedHashMap.java:684) at org.apache.dolphinscheduler.common.utils.JSONUtils.main(JSONUtils.java:256) ``` I don't find out the deep reason, but I think we should remove this method. **Which version of Dolphin Scheduler:** -[dev]
https://github.com/apache/dolphinscheduler/issues/6072
https://github.com/apache/dolphinscheduler/pull/6283
c855a5926ceb9cfb6efb0c901c8d92fe3774e999
46257834792d3316c9f5ef885f38e069e4eb6452
2021-08-31T10:30:15Z
java
2021-09-23T15:06:53Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
List<Server> masterServers = monitorService.getServerListFromRegistry(true); if (masterServers.isEmpty()) { putMsg(result, Status.MASTER_NOT_EXISTS); return false; } return true; } /** * check whether the process definition can be executed * * @param processDefinition process definition * @param processDefineCode process definition code * @return check result code */ @Override public Map<String, Object> checkProcessDefinitionValid(ProcessDefinition processDefinition, long processDefineCode) { Map<String, Object> result = new HashMap<>(); if (processDefinition == null) { putMsg(result, Status.PROCESS_DEFINE_NOT_EXIST, processDefineCode); } else if (processDefinition.getReleaseState() != ReleaseState.ONLINE) { putMsg(result, Status.PROCESS_DEFINE_NOT_RELEASE, processDefineCode); } else { result.put(Constants.STATUS, Status.SUCCESS); } return result; }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,072
[Bug][common] Generics type is invalid in JsonUtils.toMap
**Describe the bug** This method is hope to deserialize a JSON to Map. https://github.com/apache/dolphinscheduler/blob/e866d1be86464d812551e8c38ba60767a204c82e/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/JSONUtils.java#L249-L251 But the generics type in the Map is not what we expected. We can write a simple test case: ```java String sqlResult = "{\"id\":[],\"test1\":\"6\"}"; Map<String, List> param = toMap(sqlResult, String.class, List.class); System.out.println(param); ``` It will execute success, and print ``` {id=[], test1=6} ``` The value type of `id` is `List`, the value type of `test1` is `String`. But If we loop the map, it will throw a exception, because the value in this map has different type ```java String sqlResult = "{\"id\":[],\"test1\":\"6\"}"; Map<String, List> param = toMap(sqlResult, String.class, List.class); param.forEach((key, value) -> System.out.println(value)); ``` ``` [] Exception in thread "main" java.lang.ClassCastException: java.lang.String cannot be cast to java.util.List at java.util.LinkedHashMap.forEach(LinkedHashMap.java:684) at org.apache.dolphinscheduler.common.utils.JSONUtils.main(JSONUtils.java:256) ``` I don't find out the deep reason, but I think we should remove this method. **Which version of Dolphin Scheduler:** -[dev]
https://github.com/apache/dolphinscheduler/issues/6072
https://github.com/apache/dolphinscheduler/pull/6283
c855a5926ceb9cfb6efb0c901c8d92fe3774e999
46257834792d3316c9f5ef885f38e069e4eb6452
2021-08-31T10:30:15Z
java
2021-09-23T15:06:53Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
/** * do action to process instance:pause, stop, repeat, recover from pause, recover from stop * * @param loginUser login user * @param projectCode project code * @param processInstanceId process instance id * @param executeType execute type * @return execute result code */ @Override public Map<String, Object> execute(User loginUser, long projectCode, Integer processInstanceId, ExecuteType executeType) { Project project = projectMapper.queryByCode(projectCode); Map<String, Object> result = projectService.checkProjectAndAuth(loginUser, project, projectCode); if (result.get(Constants.STATUS) != Status.SUCCESS) { return result; } if (!checkMasterExists(result)) { return result; } ProcessInstance processInstance = processService.findProcessInstanceDetailById(processInstanceId); if (processInstance == null) { putMsg(result, Status.PROCESS_INSTANCE_NOT_EXIST, processInstanceId); return result; } ProcessDefinition processDefinition = processService.findProcessDefinition(processInstance.getProcessDefinitionCode(), processInstance.getProcessDefinitionVersion()); if (executeType != ExecuteType.STOP && executeType != ExecuteType.PAUSE) { result = checkProcessDefinitionValid(processDefinition, processInstance.getProcessDefinitionCode());
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,072
[Bug][common] Generics type is invalid in JsonUtils.toMap
**Describe the bug** This method is hope to deserialize a JSON to Map. https://github.com/apache/dolphinscheduler/blob/e866d1be86464d812551e8c38ba60767a204c82e/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/JSONUtils.java#L249-L251 But the generics type in the Map is not what we expected. We can write a simple test case: ```java String sqlResult = "{\"id\":[],\"test1\":\"6\"}"; Map<String, List> param = toMap(sqlResult, String.class, List.class); System.out.println(param); ``` It will execute success, and print ``` {id=[], test1=6} ``` The value type of `id` is `List`, the value type of `test1` is `String`. But If we loop the map, it will throw a exception, because the value in this map has different type ```java String sqlResult = "{\"id\":[],\"test1\":\"6\"}"; Map<String, List> param = toMap(sqlResult, String.class, List.class); param.forEach((key, value) -> System.out.println(value)); ``` ``` [] Exception in thread "main" java.lang.ClassCastException: java.lang.String cannot be cast to java.util.List at java.util.LinkedHashMap.forEach(LinkedHashMap.java:684) at org.apache.dolphinscheduler.common.utils.JSONUtils.main(JSONUtils.java:256) ``` I don't find out the deep reason, but I think we should remove this method. **Which version of Dolphin Scheduler:** -[dev]
https://github.com/apache/dolphinscheduler/issues/6072
https://github.com/apache/dolphinscheduler/pull/6283
c855a5926ceb9cfb6efb0c901c8d92fe3774e999
46257834792d3316c9f5ef885f38e069e4eb6452
2021-08-31T10:30:15Z
java
2021-09-23T15:06:53Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
if (result.get(Constants.STATUS) != Status.SUCCESS) { return result; } } result = checkExecuteType(processInstance, executeType); if (result.get(Constants.STATUS) != Status.SUCCESS) { return result; } if (!checkTenantSuitable(processDefinition)) { logger.error("there is not any valid tenant for the process definition: id:{},name:{}, ", processDefinition.getId(), processDefinition.getName()); putMsg(result, Status.TENANT_NOT_SUITABLE); } // Map<String, Object> commandMap = JSONUtils.toMap(processInstance.getCommandParam(), String.class, Object.class); String startParams = null; if (MapUtils.isNotEmpty(commandMap) && executeType == ExecuteType.REPEAT_RUNNING) { Object startParamsJson = commandMap.get(Constants.CMD_PARAM_START_PARAMS); if (startParamsJson != null) { startParams = startParamsJson.toString(); } } switch (executeType) { case REPEAT_RUNNING: result = insertCommand(loginUser, processInstanceId, processDefinition.getCode(), CommandType.REPEAT_RUNNING, startParams); break; case RECOVER_SUSPENDED_PROCESS: result = insertCommand(loginUser, processInstanceId, processDefinition.getCode(), CommandType.RECOVER_SUSPENDED_PROCESS, startParams); break; case START_FAILURE_TASK_PROCESS:
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,072
[Bug][common] Generics type is invalid in JsonUtils.toMap
**Describe the bug** This method is hope to deserialize a JSON to Map. https://github.com/apache/dolphinscheduler/blob/e866d1be86464d812551e8c38ba60767a204c82e/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/JSONUtils.java#L249-L251 But the generics type in the Map is not what we expected. We can write a simple test case: ```java String sqlResult = "{\"id\":[],\"test1\":\"6\"}"; Map<String, List> param = toMap(sqlResult, String.class, List.class); System.out.println(param); ``` It will execute success, and print ``` {id=[], test1=6} ``` The value type of `id` is `List`, the value type of `test1` is `String`. But If we loop the map, it will throw a exception, because the value in this map has different type ```java String sqlResult = "{\"id\":[],\"test1\":\"6\"}"; Map<String, List> param = toMap(sqlResult, String.class, List.class); param.forEach((key, value) -> System.out.println(value)); ``` ``` [] Exception in thread "main" java.lang.ClassCastException: java.lang.String cannot be cast to java.util.List at java.util.LinkedHashMap.forEach(LinkedHashMap.java:684) at org.apache.dolphinscheduler.common.utils.JSONUtils.main(JSONUtils.java:256) ``` I don't find out the deep reason, but I think we should remove this method. **Which version of Dolphin Scheduler:** -[dev]
https://github.com/apache/dolphinscheduler/issues/6072
https://github.com/apache/dolphinscheduler/pull/6283
c855a5926ceb9cfb6efb0c901c8d92fe3774e999
46257834792d3316c9f5ef885f38e069e4eb6452
2021-08-31T10:30:15Z
java
2021-09-23T15:06:53Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
result = insertCommand(loginUser, processInstanceId, processDefinition.getCode(), CommandType.START_FAILURE_TASK_PROCESS, startParams); break; case STOP: if (processInstance.getState() == ExecutionStatus.READY_STOP) { putMsg(result, Status.PROCESS_INSTANCE_ALREADY_CHANGED, processInstance.getName(), processInstance.getState()); } else { result = updateProcessInstancePrepare(processInstance, CommandType.STOP, ExecutionStatus.READY_STOP); } break; case PAUSE: if (processInstance.getState() == ExecutionStatus.READY_PAUSE) { putMsg(result, Status.PROCESS_INSTANCE_ALREADY_CHANGED, processInstance.getName(), processInstance.getState()); } else { result = updateProcessInstancePrepare(processInstance, CommandType.PAUSE, ExecutionStatus.READY_PAUSE); } break; default: logger.error("unknown execute type : {}", executeType); putMsg(result, Status.REQUEST_PARAMS_NOT_VALID_ERROR, "unknown execute type"); break; } return result; } /** * check tenant suitable * * @param processDefinition process definition * @return true if tenant suitable, otherwise return false */ private boolean checkTenantSuitable(ProcessDefinition processDefinition) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,072
[Bug][common] Generics type is invalid in JsonUtils.toMap
**Describe the bug** This method is hope to deserialize a JSON to Map. https://github.com/apache/dolphinscheduler/blob/e866d1be86464d812551e8c38ba60767a204c82e/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/JSONUtils.java#L249-L251 But the generics type in the Map is not what we expected. We can write a simple test case: ```java String sqlResult = "{\"id\":[],\"test1\":\"6\"}"; Map<String, List> param = toMap(sqlResult, String.class, List.class); System.out.println(param); ``` It will execute success, and print ``` {id=[], test1=6} ``` The value type of `id` is `List`, the value type of `test1` is `String`. But If we loop the map, it will throw a exception, because the value in this map has different type ```java String sqlResult = "{\"id\":[],\"test1\":\"6\"}"; Map<String, List> param = toMap(sqlResult, String.class, List.class); param.forEach((key, value) -> System.out.println(value)); ``` ``` [] Exception in thread "main" java.lang.ClassCastException: java.lang.String cannot be cast to java.util.List at java.util.LinkedHashMap.forEach(LinkedHashMap.java:684) at org.apache.dolphinscheduler.common.utils.JSONUtils.main(JSONUtils.java:256) ``` I don't find out the deep reason, but I think we should remove this method. **Which version of Dolphin Scheduler:** -[dev]
https://github.com/apache/dolphinscheduler/issues/6072
https://github.com/apache/dolphinscheduler/pull/6283
c855a5926ceb9cfb6efb0c901c8d92fe3774e999
46257834792d3316c9f5ef885f38e069e4eb6452
2021-08-31T10:30:15Z
java
2021-09-23T15:06:53Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
Tenant tenant = processService.getTenantForProcess(processDefinition.getTenantId(), processDefinition.getUserId()); return tenant != null; } /** * Check the state of process instance and the type of operation match * * @param processInstance process instance * @param executeType execute type * @return check result code */ private Map<String, Object> checkExecuteType(ProcessInstance processInstance, ExecuteType executeType) { Map<String, Object> result = new HashMap<>(); ExecutionStatus executionStatus = processInstance.getState(); boolean checkResult = false; switch (executeType) { case PAUSE: case STOP: if (executionStatus.typeIsRunning()) { checkResult = true; } break; case REPEAT_RUNNING: if (executionStatus.typeIsFinished()) { checkResult = true; } break; case START_FAILURE_TASK_PROCESS: if (executionStatus.typeIsFailure()) { checkResult = true;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,072
[Bug][common] Generics type is invalid in JsonUtils.toMap
**Describe the bug** This method is hope to deserialize a JSON to Map. https://github.com/apache/dolphinscheduler/blob/e866d1be86464d812551e8c38ba60767a204c82e/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/JSONUtils.java#L249-L251 But the generics type in the Map is not what we expected. We can write a simple test case: ```java String sqlResult = "{\"id\":[],\"test1\":\"6\"}"; Map<String, List> param = toMap(sqlResult, String.class, List.class); System.out.println(param); ``` It will execute success, and print ``` {id=[], test1=6} ``` The value type of `id` is `List`, the value type of `test1` is `String`. But If we loop the map, it will throw a exception, because the value in this map has different type ```java String sqlResult = "{\"id\":[],\"test1\":\"6\"}"; Map<String, List> param = toMap(sqlResult, String.class, List.class); param.forEach((key, value) -> System.out.println(value)); ``` ``` [] Exception in thread "main" java.lang.ClassCastException: java.lang.String cannot be cast to java.util.List at java.util.LinkedHashMap.forEach(LinkedHashMap.java:684) at org.apache.dolphinscheduler.common.utils.JSONUtils.main(JSONUtils.java:256) ``` I don't find out the deep reason, but I think we should remove this method. **Which version of Dolphin Scheduler:** -[dev]
https://github.com/apache/dolphinscheduler/issues/6072
https://github.com/apache/dolphinscheduler/pull/6283
c855a5926ceb9cfb6efb0c901c8d92fe3774e999
46257834792d3316c9f5ef885f38e069e4eb6452
2021-08-31T10:30:15Z
java
2021-09-23T15:06:53Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
} break; case RECOVER_SUSPENDED_PROCESS: if (executionStatus.typeIsPause() || executionStatus.typeIsCancel()) { checkResult = true; } break; default: break; } if (!checkResult) { putMsg(result, Status.PROCESS_INSTANCE_STATE_OPERATION_ERROR, processInstance.getName(), executionStatus.toString(), executeType.toString()); } else { putMsg(result, Status.SUCCESS); } return result; } /** * prepare to update process instance command type and status * * @param processInstance process instance * @param commandType command type * @param executionStatus execute status * @return update result */ private Map<String, Object> updateProcessInstancePrepare(ProcessInstance processInstance, CommandType commandType, ExecutionStatus executionStatus) { Map<String, Object> result = new HashMap<>(); processInstance.setCommandType(commandType); processInstance.addHistoryCmd(commandType); processInstance.setState(executionStatus);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,072
[Bug][common] Generics type is invalid in JsonUtils.toMap
**Describe the bug** This method is hope to deserialize a JSON to Map. https://github.com/apache/dolphinscheduler/blob/e866d1be86464d812551e8c38ba60767a204c82e/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/JSONUtils.java#L249-L251 But the generics type in the Map is not what we expected. We can write a simple test case: ```java String sqlResult = "{\"id\":[],\"test1\":\"6\"}"; Map<String, List> param = toMap(sqlResult, String.class, List.class); System.out.println(param); ``` It will execute success, and print ``` {id=[], test1=6} ``` The value type of `id` is `List`, the value type of `test1` is `String`. But If we loop the map, it will throw a exception, because the value in this map has different type ```java String sqlResult = "{\"id\":[],\"test1\":\"6\"}"; Map<String, List> param = toMap(sqlResult, String.class, List.class); param.forEach((key, value) -> System.out.println(value)); ``` ``` [] Exception in thread "main" java.lang.ClassCastException: java.lang.String cannot be cast to java.util.List at java.util.LinkedHashMap.forEach(LinkedHashMap.java:684) at org.apache.dolphinscheduler.common.utils.JSONUtils.main(JSONUtils.java:256) ``` I don't find out the deep reason, but I think we should remove this method. **Which version of Dolphin Scheduler:** -[dev]
https://github.com/apache/dolphinscheduler/issues/6072
https://github.com/apache/dolphinscheduler/pull/6283
c855a5926ceb9cfb6efb0c901c8d92fe3774e999
46257834792d3316c9f5ef885f38e069e4eb6452
2021-08-31T10:30:15Z
java
2021-09-23T15:06:53Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
int update = processService.updateProcessInstance(processInstance); // if (update > 0) { String host = processInstance.getHost(); String address = host.split(":")[0]; int port = Integer.parseInt(host.split(":")[1]); StateEventChangeCommand stateEventChangeCommand = new StateEventChangeCommand( processInstance.getId(), 0, processInstance.getState(), processInstance.getId(), 0 ); stateEventCallbackService.sendResult(address, port, stateEventChangeCommand.convert2Command()); putMsg(result, Status.SUCCESS); } else { putMsg(result, Status.EXECUTE_PROCESS_INSTANCE_ERROR); } return result; } /** * insert command, used in the implementation of the page, re run, recovery (pause / failure) execution * * @param loginUser login user * @param instanceId instance id * @param processDefinitionCode process definition code * @param commandType command type * @return insert result code */ private Map<String, Object> insertCommand(User loginUser, Integer instanceId, long processDefinitionCode, CommandType commandType, String startParams) { Map<String, Object> result = new HashMap<>(); // Map<String, Object> cmdParam = new HashMap<>(); cmdParam.put(CMD_PARAM_RECOVER_PROCESS_ID_STRING, instanceId);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,072
[Bug][common] Generics type is invalid in JsonUtils.toMap
**Describe the bug** This method is hope to deserialize a JSON to Map. https://github.com/apache/dolphinscheduler/blob/e866d1be86464d812551e8c38ba60767a204c82e/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/JSONUtils.java#L249-L251 But the generics type in the Map is not what we expected. We can write a simple test case: ```java String sqlResult = "{\"id\":[],\"test1\":\"6\"}"; Map<String, List> param = toMap(sqlResult, String.class, List.class); System.out.println(param); ``` It will execute success, and print ``` {id=[], test1=6} ``` The value type of `id` is `List`, the value type of `test1` is `String`. But If we loop the map, it will throw a exception, because the value in this map has different type ```java String sqlResult = "{\"id\":[],\"test1\":\"6\"}"; Map<String, List> param = toMap(sqlResult, String.class, List.class); param.forEach((key, value) -> System.out.println(value)); ``` ``` [] Exception in thread "main" java.lang.ClassCastException: java.lang.String cannot be cast to java.util.List at java.util.LinkedHashMap.forEach(LinkedHashMap.java:684) at org.apache.dolphinscheduler.common.utils.JSONUtils.main(JSONUtils.java:256) ``` I don't find out the deep reason, but I think we should remove this method. **Which version of Dolphin Scheduler:** -[dev]
https://github.com/apache/dolphinscheduler/issues/6072
https://github.com/apache/dolphinscheduler/pull/6283
c855a5926ceb9cfb6efb0c901c8d92fe3774e999
46257834792d3316c9f5ef885f38e069e4eb6452
2021-08-31T10:30:15Z
java
2021-09-23T15:06:53Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
if (!StringUtils.isEmpty(startParams)) { cmdParam.put(CMD_PARAM_START_PARAMS, startParams); } Command command = new Command(); command.setCommandType(commandType); command.setProcessDefinitionCode(processDefinitionCode); command.setCommandParam(JSONUtils.toJsonString(cmdParam)); command.setExecutorId(loginUser.getId()); if (!processService.verifyIsNeedCreateCommand(command)) { putMsg(result, Status.PROCESS_INSTANCE_EXECUTING_COMMAND, processDefinitionCode); return result; } int create = processService.createCommand(command); if (create > 0) { putMsg(result, Status.SUCCESS); } else { putMsg(result, Status.EXECUTE_PROCESS_INSTANCE_ERROR); } return result; } /** * check if sub processes are offline before starting process definition * * @param processDefinitionCode process definition code * @return check result code */ @Override public Map<String, Object> startCheckByProcessDefinedCode(long processDefinitionCode) { Map<String, Object> result = new HashMap<>(); ProcessDefinition processDefinition = processDefinitionMapper.queryByCode(processDefinitionCode);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,072
[Bug][common] Generics type is invalid in JsonUtils.toMap
**Describe the bug** This method is hope to deserialize a JSON to Map. https://github.com/apache/dolphinscheduler/blob/e866d1be86464d812551e8c38ba60767a204c82e/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/JSONUtils.java#L249-L251 But the generics type in the Map is not what we expected. We can write a simple test case: ```java String sqlResult = "{\"id\":[],\"test1\":\"6\"}"; Map<String, List> param = toMap(sqlResult, String.class, List.class); System.out.println(param); ``` It will execute success, and print ``` {id=[], test1=6} ``` The value type of `id` is `List`, the value type of `test1` is `String`. But If we loop the map, it will throw a exception, because the value in this map has different type ```java String sqlResult = "{\"id\":[],\"test1\":\"6\"}"; Map<String, List> param = toMap(sqlResult, String.class, List.class); param.forEach((key, value) -> System.out.println(value)); ``` ``` [] Exception in thread "main" java.lang.ClassCastException: java.lang.String cannot be cast to java.util.List at java.util.LinkedHashMap.forEach(LinkedHashMap.java:684) at org.apache.dolphinscheduler.common.utils.JSONUtils.main(JSONUtils.java:256) ``` I don't find out the deep reason, but I think we should remove this method. **Which version of Dolphin Scheduler:** -[dev]
https://github.com/apache/dolphinscheduler/issues/6072
https://github.com/apache/dolphinscheduler/pull/6283
c855a5926ceb9cfb6efb0c901c8d92fe3774e999
46257834792d3316c9f5ef885f38e069e4eb6452
2021-08-31T10:30:15Z
java
2021-09-23T15:06:53Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
if (processDefinition == null) { logger.error("process definition is not found"); putMsg(result, Status.REQUEST_PARAMS_NOT_VALID_ERROR, "processDefinitionCode"); return result; } List<Integer> ids = new ArrayList<>(); processService.recurseFindSubProcessId(processDefinition.getId(), ids); Integer[] idArray = ids.toArray(new Integer[ids.size()]); if (!ids.isEmpty()) { List<ProcessDefinition> processDefinitionList = processDefinitionMapper.queryDefinitionListByIdList(idArray); if (processDefinitionList != null) { for (ProcessDefinition processDefinitionTmp : processDefinitionList) { /** * if there is no online process, exit directly */ if (processDefinitionTmp.getReleaseState() != ReleaseState.ONLINE) { putMsg(result, Status.PROCESS_DEFINE_NOT_RELEASE, processDefinitionTmp.getName()); logger.info("not release process definition id: {} , name : {}", processDefinitionTmp.getId(), processDefinitionTmp.getName()); return result; } } } } putMsg(result, Status.SUCCESS); return result; } /** * create command *
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,072
[Bug][common] Generics type is invalid in JsonUtils.toMap
**Describe the bug** This method is hope to deserialize a JSON to Map. https://github.com/apache/dolphinscheduler/blob/e866d1be86464d812551e8c38ba60767a204c82e/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/JSONUtils.java#L249-L251 But the generics type in the Map is not what we expected. We can write a simple test case: ```java String sqlResult = "{\"id\":[],\"test1\":\"6\"}"; Map<String, List> param = toMap(sqlResult, String.class, List.class); System.out.println(param); ``` It will execute success, and print ``` {id=[], test1=6} ``` The value type of `id` is `List`, the value type of `test1` is `String`. But If we loop the map, it will throw a exception, because the value in this map has different type ```java String sqlResult = "{\"id\":[],\"test1\":\"6\"}"; Map<String, List> param = toMap(sqlResult, String.class, List.class); param.forEach((key, value) -> System.out.println(value)); ``` ``` [] Exception in thread "main" java.lang.ClassCastException: java.lang.String cannot be cast to java.util.List at java.util.LinkedHashMap.forEach(LinkedHashMap.java:684) at org.apache.dolphinscheduler.common.utils.JSONUtils.main(JSONUtils.java:256) ``` I don't find out the deep reason, but I think we should remove this method. **Which version of Dolphin Scheduler:** -[dev]
https://github.com/apache/dolphinscheduler/issues/6072
https://github.com/apache/dolphinscheduler/pull/6283
c855a5926ceb9cfb6efb0c901c8d92fe3774e999
46257834792d3316c9f5ef885f38e069e4eb6452
2021-08-31T10:30:15Z
java
2021-09-23T15:06:53Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
* @param commandType commandType * @param processDefineCode processDefineCode * @param nodeDep nodeDep * @param failureStrategy failureStrategy * @param startNodeList startNodeList * @param schedule schedule * @param warningType warningType * @param executorId executorId * @param warningGroupId warningGroupId * @param runMode runMode * @param processInstancePriority processInstancePriority * @param workerGroup workerGroup * @param environmentCode environmentCode * @return command id */ private int createCommand(CommandType commandType, long processDefineCode, TaskDependType nodeDep, FailureStrategy failureStrategy, String startNodeList, String schedule, WarningType warningType, int executorId, int warningGroupId, RunMode runMode, Priority processInstancePriority, String workerGroup, Long environmentCode, Map<String, String> startParams, Integer expectedParallelismNumber) { /** * instantiate command schedule instance */ Command command = new Command(); Map<String, String> cmdParam = new HashMap<>(); if (commandType == null) { command.setCommandType(CommandType.START_PROCESS); } else { command.setCommandType(commandType);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,072
[Bug][common] Generics type is invalid in JsonUtils.toMap
**Describe the bug** This method is hope to deserialize a JSON to Map. https://github.com/apache/dolphinscheduler/blob/e866d1be86464d812551e8c38ba60767a204c82e/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/JSONUtils.java#L249-L251 But the generics type in the Map is not what we expected. We can write a simple test case: ```java String sqlResult = "{\"id\":[],\"test1\":\"6\"}"; Map<String, List> param = toMap(sqlResult, String.class, List.class); System.out.println(param); ``` It will execute success, and print ``` {id=[], test1=6} ``` The value type of `id` is `List`, the value type of `test1` is `String`. But If we loop the map, it will throw a exception, because the value in this map has different type ```java String sqlResult = "{\"id\":[],\"test1\":\"6\"}"; Map<String, List> param = toMap(sqlResult, String.class, List.class); param.forEach((key, value) -> System.out.println(value)); ``` ``` [] Exception in thread "main" java.lang.ClassCastException: java.lang.String cannot be cast to java.util.List at java.util.LinkedHashMap.forEach(LinkedHashMap.java:684) at org.apache.dolphinscheduler.common.utils.JSONUtils.main(JSONUtils.java:256) ``` I don't find out the deep reason, but I think we should remove this method. **Which version of Dolphin Scheduler:** -[dev]
https://github.com/apache/dolphinscheduler/issues/6072
https://github.com/apache/dolphinscheduler/pull/6283
c855a5926ceb9cfb6efb0c901c8d92fe3774e999
46257834792d3316c9f5ef885f38e069e4eb6452
2021-08-31T10:30:15Z
java
2021-09-23T15:06:53Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
} command.setProcessDefinitionCode(processDefineCode); if (nodeDep != null) { command.setTaskDependType(nodeDep); } if (failureStrategy != null) { command.setFailureStrategy(failureStrategy); } if (!StringUtils.isEmpty(startNodeList)) { cmdParam.put(CMD_PARAM_START_NODE_NAMES, startNodeList); } if (warningType != null) { command.setWarningType(warningType); } if (startParams != null && startParams.size() > 0) { cmdParam.put(CMD_PARAM_START_PARAMS, JSONUtils.toJsonString(startParams)); } command.setCommandParam(JSONUtils.toJsonString(cmdParam)); command.setExecutorId(executorId); command.setWarningGroupId(warningGroupId); command.setProcessInstancePriority(processInstancePriority); command.setWorkerGroup(workerGroup); command.setEnvironmentCode(environmentCode); Date start = null; Date end = null; if (!StringUtils.isEmpty(schedule)) { String[] interval = schedule.split(","); if (interval.length == 2) { start = DateUtils.getScheduleDate(interval[0]); end = DateUtils.getScheduleDate(interval[1]);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,072
[Bug][common] Generics type is invalid in JsonUtils.toMap
**Describe the bug** This method is hope to deserialize a JSON to Map. https://github.com/apache/dolphinscheduler/blob/e866d1be86464d812551e8c38ba60767a204c82e/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/JSONUtils.java#L249-L251 But the generics type in the Map is not what we expected. We can write a simple test case: ```java String sqlResult = "{\"id\":[],\"test1\":\"6\"}"; Map<String, List> param = toMap(sqlResult, String.class, List.class); System.out.println(param); ``` It will execute success, and print ``` {id=[], test1=6} ``` The value type of `id` is `List`, the value type of `test1` is `String`. But If we loop the map, it will throw a exception, because the value in this map has different type ```java String sqlResult = "{\"id\":[],\"test1\":\"6\"}"; Map<String, List> param = toMap(sqlResult, String.class, List.class); param.forEach((key, value) -> System.out.println(value)); ``` ``` [] Exception in thread "main" java.lang.ClassCastException: java.lang.String cannot be cast to java.util.List at java.util.LinkedHashMap.forEach(LinkedHashMap.java:684) at org.apache.dolphinscheduler.common.utils.JSONUtils.main(JSONUtils.java:256) ``` I don't find out the deep reason, but I think we should remove this method. **Which version of Dolphin Scheduler:** -[dev]
https://github.com/apache/dolphinscheduler/issues/6072
https://github.com/apache/dolphinscheduler/pull/6283
c855a5926ceb9cfb6efb0c901c8d92fe3774e999
46257834792d3316c9f5ef885f38e069e4eb6452
2021-08-31T10:30:15Z
java
2021-09-23T15:06:53Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
} } // if (commandType == CommandType.COMPLEMENT_DATA) { runMode = (runMode == null) ? RunMode.RUN_MODE_SERIAL : runMode; if (null != start && null != end && !start.after(end)) { if (runMode == RunMode.RUN_MODE_SERIAL) { cmdParam.put(CMDPARAM_COMPLEMENT_DATA_START_DATE, DateUtils.dateToString(start)); cmdParam.put(CMDPARAM_COMPLEMENT_DATA_END_DATE, DateUtils.dateToString(end)); command.setCommandParam(JSONUtils.toJsonString(cmdParam)); return processService.createCommand(command); } else if (runMode == RunMode.RUN_MODE_PARALLEL) { List<Schedule> schedules = processService.queryReleaseSchedulerListByProcessDefinitionCode(processDefineCode); LinkedList<Date> listDate = new LinkedList<>(); if (!CollectionUtils.isEmpty(schedules)) { for (Schedule item : schedules) { listDate.addAll(CronUtils.getSelfFireDateList(start, end, item.getCrontab())); } } if (!CollectionUtils.isEmpty(listDate)) { int effectThreadsCount = expectedParallelismNumber == null ? listDate.size() : Math.min(listDate.size(), expectedParallelismNumber); logger.info("In parallel mode, current expectedParallelismNumber:{}", effectThreadsCount); int chunkSize = listDate.size() / effectThreadsCount; listDate.addFirst(start); listDate.addLast(end); for (int i = 0; i < effectThreadsCount; i++) { int rangeStart = i == 0 ? i : (i * chunkSize); int rangeEnd = i == effectThreadsCount - 1 ? listDate.size() - 1 : rangeStart + chunkSize + 1; cmdParam.put(CMDPARAM_COMPLEMENT_DATA_START_DATE, DateUtils.dateToString(listDate.get(rangeStart)));
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,072
[Bug][common] Generics type is invalid in JsonUtils.toMap
**Describe the bug** This method is hope to deserialize a JSON to Map. https://github.com/apache/dolphinscheduler/blob/e866d1be86464d812551e8c38ba60767a204c82e/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/JSONUtils.java#L249-L251 But the generics type in the Map is not what we expected. We can write a simple test case: ```java String sqlResult = "{\"id\":[],\"test1\":\"6\"}"; Map<String, List> param = toMap(sqlResult, String.class, List.class); System.out.println(param); ``` It will execute success, and print ``` {id=[], test1=6} ``` The value type of `id` is `List`, the value type of `test1` is `String`. But If we loop the map, it will throw a exception, because the value in this map has different type ```java String sqlResult = "{\"id\":[],\"test1\":\"6\"}"; Map<String, List> param = toMap(sqlResult, String.class, List.class); param.forEach((key, value) -> System.out.println(value)); ``` ``` [] Exception in thread "main" java.lang.ClassCastException: java.lang.String cannot be cast to java.util.List at java.util.LinkedHashMap.forEach(LinkedHashMap.java:684) at org.apache.dolphinscheduler.common.utils.JSONUtils.main(JSONUtils.java:256) ``` I don't find out the deep reason, but I think we should remove this method. **Which version of Dolphin Scheduler:** -[dev]
https://github.com/apache/dolphinscheduler/issues/6072
https://github.com/apache/dolphinscheduler/pull/6283
c855a5926ceb9cfb6efb0c901c8d92fe3774e999
46257834792d3316c9f5ef885f38e069e4eb6452
2021-08-31T10:30:15Z
java
2021-09-23T15:06:53Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
cmdParam.put(CMDPARAM_COMPLEMENT_DATA_END_DATE, DateUtils.dateToString(listDate.get(rangeEnd))); command.setCommandParam(JSONUtils.toJsonString(cmdParam)); processService.createCommand(command); } return effectThreadsCount; } else { // int runCunt = 0; while (!start.after(end)) { runCunt += 1; cmdParam.put(CMDPARAM_COMPLEMENT_DATA_START_DATE, DateUtils.dateToString(start)); cmdParam.put(CMDPARAM_COMPLEMENT_DATA_END_DATE, DateUtils.dateToString(start)); command.setCommandParam(JSONUtils.toJsonString(cmdParam)); processService.createCommand(command); start = DateUtils.getSomeDay(start, 1); } return runCunt; } } } else { logger.error("there is not valid schedule date for the process definition code:{}", processDefineCode); } } else { command.setCommandParam(JSONUtils.toJsonString(cmdParam)); return processService.createCommand(command); } return 0; } }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,072
[Bug][common] Generics type is invalid in JsonUtils.toMap
**Describe the bug** This method is hope to deserialize a JSON to Map. https://github.com/apache/dolphinscheduler/blob/e866d1be86464d812551e8c38ba60767a204c82e/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/JSONUtils.java#L249-L251 But the generics type in the Map is not what we expected. We can write a simple test case: ```java String sqlResult = "{\"id\":[],\"test1\":\"6\"}"; Map<String, List> param = toMap(sqlResult, String.class, List.class); System.out.println(param); ``` It will execute success, and print ``` {id=[], test1=6} ``` The value type of `id` is `List`, the value type of `test1` is `String`. But If we loop the map, it will throw a exception, because the value in this map has different type ```java String sqlResult = "{\"id\":[],\"test1\":\"6\"}"; Map<String, List> param = toMap(sqlResult, String.class, List.class); param.forEach((key, value) -> System.out.println(value)); ``` ``` [] Exception in thread "main" java.lang.ClassCastException: java.lang.String cannot be cast to java.util.List at java.util.LinkedHashMap.forEach(LinkedHashMap.java:684) at org.apache.dolphinscheduler.common.utils.JSONUtils.main(JSONUtils.java:256) ``` I don't find out the deep reason, but I think we should remove this method. **Which version of Dolphin Scheduler:** -[dev]
https://github.com/apache/dolphinscheduler/issues/6072
https://github.com/apache/dolphinscheduler/pull/6283
c855a5926ceb9cfb6efb0c901c8d92fe3774e999
46257834792d3316c9f5ef885f38e069e4eb6452
2021-08-31T10:30:15Z
java
2021-09-23T15:06:53Z
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/model/TaskNode.java
/* * 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.dolphinscheduler.common.model; import org.apache.dolphinscheduler.common.Constants; import org.apache.dolphinscheduler.common.enums.Priority;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,072
[Bug][common] Generics type is invalid in JsonUtils.toMap
**Describe the bug** This method is hope to deserialize a JSON to Map. https://github.com/apache/dolphinscheduler/blob/e866d1be86464d812551e8c38ba60767a204c82e/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/JSONUtils.java#L249-L251 But the generics type in the Map is not what we expected. We can write a simple test case: ```java String sqlResult = "{\"id\":[],\"test1\":\"6\"}"; Map<String, List> param = toMap(sqlResult, String.class, List.class); System.out.println(param); ``` It will execute success, and print ``` {id=[], test1=6} ``` The value type of `id` is `List`, the value type of `test1` is `String`. But If we loop the map, it will throw a exception, because the value in this map has different type ```java String sqlResult = "{\"id\":[],\"test1\":\"6\"}"; Map<String, List> param = toMap(sqlResult, String.class, List.class); param.forEach((key, value) -> System.out.println(value)); ``` ``` [] Exception in thread "main" java.lang.ClassCastException: java.lang.String cannot be cast to java.util.List at java.util.LinkedHashMap.forEach(LinkedHashMap.java:684) at org.apache.dolphinscheduler.common.utils.JSONUtils.main(JSONUtils.java:256) ``` I don't find out the deep reason, but I think we should remove this method. **Which version of Dolphin Scheduler:** -[dev]
https://github.com/apache/dolphinscheduler/issues/6072
https://github.com/apache/dolphinscheduler/pull/6283
c855a5926ceb9cfb6efb0c901c8d92fe3774e999
46257834792d3316c9f5ef885f38e069e4eb6452
2021-08-31T10:30:15Z
java
2021-09-23T15:06:53Z
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/model/TaskNode.java
import org.apache.dolphinscheduler.common.enums.TaskTimeoutStrategy; import org.apache.dolphinscheduler.common.enums.TaskType; import org.apache.dolphinscheduler.common.task.TaskTimeoutParameter; import org.apache.dolphinscheduler.common.utils.CollectionUtils; import org.apache.dolphinscheduler.common.utils.JSONUtils; import org.apache.commons.lang.StringUtils; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Objects; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.fasterxml.jackson.databind.annotation.JsonSerialize; public class TaskNode { /** * task node id */ private String id; /** * task node code */ private long code; /** * task node version */ private int version; /** * task node name */ private String name; /**
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,072
[Bug][common] Generics type is invalid in JsonUtils.toMap
**Describe the bug** This method is hope to deserialize a JSON to Map. https://github.com/apache/dolphinscheduler/blob/e866d1be86464d812551e8c38ba60767a204c82e/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/JSONUtils.java#L249-L251 But the generics type in the Map is not what we expected. We can write a simple test case: ```java String sqlResult = "{\"id\":[],\"test1\":\"6\"}"; Map<String, List> param = toMap(sqlResult, String.class, List.class); System.out.println(param); ``` It will execute success, and print ``` {id=[], test1=6} ``` The value type of `id` is `List`, the value type of `test1` is `String`. But If we loop the map, it will throw a exception, because the value in this map has different type ```java String sqlResult = "{\"id\":[],\"test1\":\"6\"}"; Map<String, List> param = toMap(sqlResult, String.class, List.class); param.forEach((key, value) -> System.out.println(value)); ``` ``` [] Exception in thread "main" java.lang.ClassCastException: java.lang.String cannot be cast to java.util.List at java.util.LinkedHashMap.forEach(LinkedHashMap.java:684) at org.apache.dolphinscheduler.common.utils.JSONUtils.main(JSONUtils.java:256) ``` I don't find out the deep reason, but I think we should remove this method. **Which version of Dolphin Scheduler:** -[dev]
https://github.com/apache/dolphinscheduler/issues/6072
https://github.com/apache/dolphinscheduler/pull/6283
c855a5926ceb9cfb6efb0c901c8d92fe3774e999
46257834792d3316c9f5ef885f38e069e4eb6452
2021-08-31T10:30:15Z
java
2021-09-23T15:06:53Z
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/model/TaskNode.java
* task node description */ private String desc; /** * task node type */ private String type; /** * the run flag has two states, NORMAL or FORBIDDEN */ private String runFlag; /** * the front field */ private String loc; /** * maximum number of retries */ private int maxRetryTimes; /** * Unit of retry interval: points */ private int retryInterval; /** * params information */ @JsonDeserialize(using = JSONUtils.JsonDataDeserializer.class) @JsonSerialize(using = JSONUtils.JsonDataSerializer.class) private String params; /**
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,072
[Bug][common] Generics type is invalid in JsonUtils.toMap
**Describe the bug** This method is hope to deserialize a JSON to Map. https://github.com/apache/dolphinscheduler/blob/e866d1be86464d812551e8c38ba60767a204c82e/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/JSONUtils.java#L249-L251 But the generics type in the Map is not what we expected. We can write a simple test case: ```java String sqlResult = "{\"id\":[],\"test1\":\"6\"}"; Map<String, List> param = toMap(sqlResult, String.class, List.class); System.out.println(param); ``` It will execute success, and print ``` {id=[], test1=6} ``` The value type of `id` is `List`, the value type of `test1` is `String`. But If we loop the map, it will throw a exception, because the value in this map has different type ```java String sqlResult = "{\"id\":[],\"test1\":\"6\"}"; Map<String, List> param = toMap(sqlResult, String.class, List.class); param.forEach((key, value) -> System.out.println(value)); ``` ``` [] Exception in thread "main" java.lang.ClassCastException: java.lang.String cannot be cast to java.util.List at java.util.LinkedHashMap.forEach(LinkedHashMap.java:684) at org.apache.dolphinscheduler.common.utils.JSONUtils.main(JSONUtils.java:256) ``` I don't find out the deep reason, but I think we should remove this method. **Which version of Dolphin Scheduler:** -[dev]
https://github.com/apache/dolphinscheduler/issues/6072
https://github.com/apache/dolphinscheduler/pull/6283
c855a5926ceb9cfb6efb0c901c8d92fe3774e999
46257834792d3316c9f5ef885f38e069e4eb6452
2021-08-31T10:30:15Z
java
2021-09-23T15:06:53Z
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/model/TaskNode.java
* inner dependency information */ @JsonDeserialize(using = JSONUtils.JsonDataDeserializer.class) @JsonSerialize(using = JSONUtils.JsonDataSerializer.class) private String preTasks; /** * node dependency list */ private List<PreviousTaskNode> preTaskNodeList; /** * users store additional information */ @JsonDeserialize(using = JSONUtils.JsonDataDeserializer.class) @JsonSerialize(using = JSONUtils.JsonDataSerializer.class) private String extras; /** * node dependency list */ private List<String> depList; /** * outer dependency information */ @JsonDeserialize(using = JSONUtils.JsonDataDeserializer.class) @JsonSerialize(using = JSONUtils.JsonDataSerializer.class) private String dependence; @JsonDeserialize(using = JSONUtils.JsonDataDeserializer.class) @JsonSerialize(using = JSONUtils.JsonDataSerializer.class) private String conditionResult; @JsonDeserialize(using = JSONUtils.JsonDataDeserializer.class) @JsonSerialize(using = JSONUtils.JsonDataSerializer.class)
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,072
[Bug][common] Generics type is invalid in JsonUtils.toMap
**Describe the bug** This method is hope to deserialize a JSON to Map. https://github.com/apache/dolphinscheduler/blob/e866d1be86464d812551e8c38ba60767a204c82e/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/JSONUtils.java#L249-L251 But the generics type in the Map is not what we expected. We can write a simple test case: ```java String sqlResult = "{\"id\":[],\"test1\":\"6\"}"; Map<String, List> param = toMap(sqlResult, String.class, List.class); System.out.println(param); ``` It will execute success, and print ``` {id=[], test1=6} ``` The value type of `id` is `List`, the value type of `test1` is `String`. But If we loop the map, it will throw a exception, because the value in this map has different type ```java String sqlResult = "{\"id\":[],\"test1\":\"6\"}"; Map<String, List> param = toMap(sqlResult, String.class, List.class); param.forEach((key, value) -> System.out.println(value)); ``` ``` [] Exception in thread "main" java.lang.ClassCastException: java.lang.String cannot be cast to java.util.List at java.util.LinkedHashMap.forEach(LinkedHashMap.java:684) at org.apache.dolphinscheduler.common.utils.JSONUtils.main(JSONUtils.java:256) ``` I don't find out the deep reason, but I think we should remove this method. **Which version of Dolphin Scheduler:** -[dev]
https://github.com/apache/dolphinscheduler/issues/6072
https://github.com/apache/dolphinscheduler/pull/6283
c855a5926ceb9cfb6efb0c901c8d92fe3774e999
46257834792d3316c9f5ef885f38e069e4eb6452
2021-08-31T10:30:15Z
java
2021-09-23T15:06:53Z
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/model/TaskNode.java
private String switchResult; @JsonDeserialize(using = JSONUtils.JsonDataDeserializer.class) @JsonSerialize(using = JSONUtils.JsonDataSerializer.class) private String waitStartTimeout; /** * task instance priority */ private Priority taskInstancePriority; /** * worker group */ private String workerGroup; /** * environment code */ private Long environmentCode; /** * task time out */ @JsonDeserialize(using = JSONUtils.JsonDataDeserializer.class) @JsonSerialize(using = JSONUtils.JsonDataSerializer.class) private String timeout; /** * delay execution time. */ private int delayTime; public String getId() { return id; } public void setId(String id) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,072
[Bug][common] Generics type is invalid in JsonUtils.toMap
**Describe the bug** This method is hope to deserialize a JSON to Map. https://github.com/apache/dolphinscheduler/blob/e866d1be86464d812551e8c38ba60767a204c82e/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/JSONUtils.java#L249-L251 But the generics type in the Map is not what we expected. We can write a simple test case: ```java String sqlResult = "{\"id\":[],\"test1\":\"6\"}"; Map<String, List> param = toMap(sqlResult, String.class, List.class); System.out.println(param); ``` It will execute success, and print ``` {id=[], test1=6} ``` The value type of `id` is `List`, the value type of `test1` is `String`. But If we loop the map, it will throw a exception, because the value in this map has different type ```java String sqlResult = "{\"id\":[],\"test1\":\"6\"}"; Map<String, List> param = toMap(sqlResult, String.class, List.class); param.forEach((key, value) -> System.out.println(value)); ``` ``` [] Exception in thread "main" java.lang.ClassCastException: java.lang.String cannot be cast to java.util.List at java.util.LinkedHashMap.forEach(LinkedHashMap.java:684) at org.apache.dolphinscheduler.common.utils.JSONUtils.main(JSONUtils.java:256) ``` I don't find out the deep reason, but I think we should remove this method. **Which version of Dolphin Scheduler:** -[dev]
https://github.com/apache/dolphinscheduler/issues/6072
https://github.com/apache/dolphinscheduler/pull/6283
c855a5926ceb9cfb6efb0c901c8d92fe3774e999
46257834792d3316c9f5ef885f38e069e4eb6452
2021-08-31T10:30:15Z
java
2021-09-23T15:06:53Z
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/model/TaskNode.java
this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getDesc() { return desc; } public void setDesc(String desc) { this.desc = desc; } public String getType() { return type; } public void setType(String type) { this.type = type; } public String getParams() { return params; } public void setParams(String params) { this.params = params; } public String getPreTasks() { return preTasks; } public void setPreTasks(String preTasks) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,072
[Bug][common] Generics type is invalid in JsonUtils.toMap
**Describe the bug** This method is hope to deserialize a JSON to Map. https://github.com/apache/dolphinscheduler/blob/e866d1be86464d812551e8c38ba60767a204c82e/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/JSONUtils.java#L249-L251 But the generics type in the Map is not what we expected. We can write a simple test case: ```java String sqlResult = "{\"id\":[],\"test1\":\"6\"}"; Map<String, List> param = toMap(sqlResult, String.class, List.class); System.out.println(param); ``` It will execute success, and print ``` {id=[], test1=6} ``` The value type of `id` is `List`, the value type of `test1` is `String`. But If we loop the map, it will throw a exception, because the value in this map has different type ```java String sqlResult = "{\"id\":[],\"test1\":\"6\"}"; Map<String, List> param = toMap(sqlResult, String.class, List.class); param.forEach((key, value) -> System.out.println(value)); ``` ``` [] Exception in thread "main" java.lang.ClassCastException: java.lang.String cannot be cast to java.util.List at java.util.LinkedHashMap.forEach(LinkedHashMap.java:684) at org.apache.dolphinscheduler.common.utils.JSONUtils.main(JSONUtils.java:256) ``` I don't find out the deep reason, but I think we should remove this method. **Which version of Dolphin Scheduler:** -[dev]
https://github.com/apache/dolphinscheduler/issues/6072
https://github.com/apache/dolphinscheduler/pull/6283
c855a5926ceb9cfb6efb0c901c8d92fe3774e999
46257834792d3316c9f5ef885f38e069e4eb6452
2021-08-31T10:30:15Z
java
2021-09-23T15:06:53Z
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/model/TaskNode.java
this.preTasks = preTasks; this.depList = JSONUtils.toList(preTasks, String.class); } public String getExtras() { return extras; } public void setExtras(String extras) { this.extras = extras; } public List<String> getDepList() { return depList; } public void setDepList(List<String> depList) { if (depList != null) { this.depList = depList; this.preTasks = JSONUtils.toJsonString(depList); } } public String getLoc() { return loc; } public void setLoc(String loc) { this.loc = loc; } public String getRunFlag() { return runFlag; } public void setRunFlag(String runFlag) { this.runFlag = runFlag; }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,072
[Bug][common] Generics type is invalid in JsonUtils.toMap
**Describe the bug** This method is hope to deserialize a JSON to Map. https://github.com/apache/dolphinscheduler/blob/e866d1be86464d812551e8c38ba60767a204c82e/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/JSONUtils.java#L249-L251 But the generics type in the Map is not what we expected. We can write a simple test case: ```java String sqlResult = "{\"id\":[],\"test1\":\"6\"}"; Map<String, List> param = toMap(sqlResult, String.class, List.class); System.out.println(param); ``` It will execute success, and print ``` {id=[], test1=6} ``` The value type of `id` is `List`, the value type of `test1` is `String`. But If we loop the map, it will throw a exception, because the value in this map has different type ```java String sqlResult = "{\"id\":[],\"test1\":\"6\"}"; Map<String, List> param = toMap(sqlResult, String.class, List.class); param.forEach((key, value) -> System.out.println(value)); ``` ``` [] Exception in thread "main" java.lang.ClassCastException: java.lang.String cannot be cast to java.util.List at java.util.LinkedHashMap.forEach(LinkedHashMap.java:684) at org.apache.dolphinscheduler.common.utils.JSONUtils.main(JSONUtils.java:256) ``` I don't find out the deep reason, but I think we should remove this method. **Which version of Dolphin Scheduler:** -[dev]
https://github.com/apache/dolphinscheduler/issues/6072
https://github.com/apache/dolphinscheduler/pull/6283
c855a5926ceb9cfb6efb0c901c8d92fe3774e999
46257834792d3316c9f5ef885f38e069e4eb6452
2021-08-31T10:30:15Z
java
2021-09-23T15:06:53Z
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/model/TaskNode.java
public Boolean isForbidden() { return (!StringUtils.isEmpty(this.runFlag) && this.runFlag.equals(Constants.FLOWNODE_RUN_FLAG_FORBIDDEN)); } @Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } TaskNode taskNode = (TaskNode) o; return Objects.equals(name, taskNode.name) && Objects.equals(desc, taskNode.desc) && Objects.equals(type, taskNode.type) && Objects.equals(params, taskNode.params) && Objects.equals(preTasks, taskNode.preTasks) && Objects.equals(extras, taskNode.extras) && Objects.equals(runFlag, taskNode.runFlag) && Objects.equals(dependence, taskNode.dependence) && Objects.equals(workerGroup, taskNode.workerGroup) && Objects.equals(environmentCode, taskNode.environmentCode) && Objects.equals(conditionResult, taskNode.conditionResult) && CollectionUtils.equalLists(depList, taskNode.depList); } @Override public int hashCode() { return Objects.hash(name, desc, type, params, preTasks, extras, depList, runFlag); }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,072
[Bug][common] Generics type is invalid in JsonUtils.toMap
**Describe the bug** This method is hope to deserialize a JSON to Map. https://github.com/apache/dolphinscheduler/blob/e866d1be86464d812551e8c38ba60767a204c82e/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/JSONUtils.java#L249-L251 But the generics type in the Map is not what we expected. We can write a simple test case: ```java String sqlResult = "{\"id\":[],\"test1\":\"6\"}"; Map<String, List> param = toMap(sqlResult, String.class, List.class); System.out.println(param); ``` It will execute success, and print ``` {id=[], test1=6} ``` The value type of `id` is `List`, the value type of `test1` is `String`. But If we loop the map, it will throw a exception, because the value in this map has different type ```java String sqlResult = "{\"id\":[],\"test1\":\"6\"}"; Map<String, List> param = toMap(sqlResult, String.class, List.class); param.forEach((key, value) -> System.out.println(value)); ``` ``` [] Exception in thread "main" java.lang.ClassCastException: java.lang.String cannot be cast to java.util.List at java.util.LinkedHashMap.forEach(LinkedHashMap.java:684) at org.apache.dolphinscheduler.common.utils.JSONUtils.main(JSONUtils.java:256) ``` I don't find out the deep reason, but I think we should remove this method. **Which version of Dolphin Scheduler:** -[dev]
https://github.com/apache/dolphinscheduler/issues/6072
https://github.com/apache/dolphinscheduler/pull/6283
c855a5926ceb9cfb6efb0c901c8d92fe3774e999
46257834792d3316c9f5ef885f38e069e4eb6452
2021-08-31T10:30:15Z
java
2021-09-23T15:06:53Z
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/model/TaskNode.java
public String getDependence() { return dependence; } public void setDependence(String dependence) { this.dependence = dependence; } public int getMaxRetryTimes() { return maxRetryTimes; } public void setMaxRetryTimes(int maxRetryTimes) { this.maxRetryTimes = maxRetryTimes; } public int getRetryInterval() { return retryInterval; } public void setRetryInterval(int retryInterval) { this.retryInterval = retryInterval; } public Priority getTaskInstancePriority() { return taskInstancePriority; } public void setTaskInstancePriority(Priority taskInstancePriority) { this.taskInstancePriority = taskInstancePriority; } public String getTimeout() { return timeout; } public void setTimeout(String timeout) { this.timeout = timeout; }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,072
[Bug][common] Generics type is invalid in JsonUtils.toMap
**Describe the bug** This method is hope to deserialize a JSON to Map. https://github.com/apache/dolphinscheduler/blob/e866d1be86464d812551e8c38ba60767a204c82e/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/JSONUtils.java#L249-L251 But the generics type in the Map is not what we expected. We can write a simple test case: ```java String sqlResult = "{\"id\":[],\"test1\":\"6\"}"; Map<String, List> param = toMap(sqlResult, String.class, List.class); System.out.println(param); ``` It will execute success, and print ``` {id=[], test1=6} ``` The value type of `id` is `List`, the value type of `test1` is `String`. But If we loop the map, it will throw a exception, because the value in this map has different type ```java String sqlResult = "{\"id\":[],\"test1\":\"6\"}"; Map<String, List> param = toMap(sqlResult, String.class, List.class); param.forEach((key, value) -> System.out.println(value)); ``` ``` [] Exception in thread "main" java.lang.ClassCastException: java.lang.String cannot be cast to java.util.List at java.util.LinkedHashMap.forEach(LinkedHashMap.java:684) at org.apache.dolphinscheduler.common.utils.JSONUtils.main(JSONUtils.java:256) ``` I don't find out the deep reason, but I think we should remove this method. **Which version of Dolphin Scheduler:** -[dev]
https://github.com/apache/dolphinscheduler/issues/6072
https://github.com/apache/dolphinscheduler/pull/6283
c855a5926ceb9cfb6efb0c901c8d92fe3774e999
46257834792d3316c9f5ef885f38e069e4eb6452
2021-08-31T10:30:15Z
java
2021-09-23T15:06:53Z
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/model/TaskNode.java
public String getWorkerGroup() { return workerGroup; } public void setWorkerGroup(String workerGroup) { this.workerGroup = workerGroup; } public String getConditionResult() { return conditionResult; } public void setConditionResult(String conditionResult) { this.conditionResult = conditionResult; } public int getDelayTime() { return delayTime; } public void setDelayTime(int delayTime) { this.delayTime = delayTime; } public long getCode() { return code; } public void setCode(long code) { this.code = code; } public int getVersion() { return version; } public void setVersion(int version) { this.version = version; }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,072
[Bug][common] Generics type is invalid in JsonUtils.toMap
**Describe the bug** This method is hope to deserialize a JSON to Map. https://github.com/apache/dolphinscheduler/blob/e866d1be86464d812551e8c38ba60767a204c82e/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/JSONUtils.java#L249-L251 But the generics type in the Map is not what we expected. We can write a simple test case: ```java String sqlResult = "{\"id\":[],\"test1\":\"6\"}"; Map<String, List> param = toMap(sqlResult, String.class, List.class); System.out.println(param); ``` It will execute success, and print ``` {id=[], test1=6} ``` The value type of `id` is `List`, the value type of `test1` is `String`. But If we loop the map, it will throw a exception, because the value in this map has different type ```java String sqlResult = "{\"id\":[],\"test1\":\"6\"}"; Map<String, List> param = toMap(sqlResult, String.class, List.class); param.forEach((key, value) -> System.out.println(value)); ``` ``` [] Exception in thread "main" java.lang.ClassCastException: java.lang.String cannot be cast to java.util.List at java.util.LinkedHashMap.forEach(LinkedHashMap.java:684) at org.apache.dolphinscheduler.common.utils.JSONUtils.main(JSONUtils.java:256) ``` I don't find out the deep reason, but I think we should remove this method. **Which version of Dolphin Scheduler:** -[dev]
https://github.com/apache/dolphinscheduler/issues/6072
https://github.com/apache/dolphinscheduler/pull/6283
c855a5926ceb9cfb6efb0c901c8d92fe3774e999
46257834792d3316c9f5ef885f38e069e4eb6452
2021-08-31T10:30:15Z
java
2021-09-23T15:06:53Z
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/model/TaskNode.java
/** * get task time out parameter * * @return task time out parameter */ public TaskTimeoutParameter getTaskTimeoutParameter() { if (!StringUtils.isEmpty(this.getTimeout())) { String formatStr = String.format("%s,%s", TaskTimeoutStrategy.WARN.name(), TaskTimeoutStrategy.FAILED.name()); String taskTimeout = this.getTimeout().replace(formatStr, TaskTimeoutStrategy.WARNFAILED.name()); return JSONUtils.parseObject(taskTimeout, TaskTimeoutParameter.class); } return new TaskTimeoutParameter(false); } public boolean isConditionsTask() { return TaskType.CONDITIONS.getDesc().equalsIgnoreCase(this.getType()); } public boolean isSwitchTask() { return TaskType.SWITCH.toString().equalsIgnoreCase(this.getType()); } public List<PreviousTaskNode> getPreTaskNodeList() { return preTaskNodeList; } public void setPreTaskNodeList(List<PreviousTaskNode> preTaskNodeList) { this.preTaskNodeList = preTaskNodeList; } public String getTaskParams() { Map<String, Object> taskParams = JSONUtils.toMap(this.params, String.class, Object.class); if (taskParams == null) { taskParams = new HashMap<>(); }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,072
[Bug][common] Generics type is invalid in JsonUtils.toMap
**Describe the bug** This method is hope to deserialize a JSON to Map. https://github.com/apache/dolphinscheduler/blob/e866d1be86464d812551e8c38ba60767a204c82e/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/JSONUtils.java#L249-L251 But the generics type in the Map is not what we expected. We can write a simple test case: ```java String sqlResult = "{\"id\":[],\"test1\":\"6\"}"; Map<String, List> param = toMap(sqlResult, String.class, List.class); System.out.println(param); ``` It will execute success, and print ``` {id=[], test1=6} ``` The value type of `id` is `List`, the value type of `test1` is `String`. But If we loop the map, it will throw a exception, because the value in this map has different type ```java String sqlResult = "{\"id\":[],\"test1\":\"6\"}"; Map<String, List> param = toMap(sqlResult, String.class, List.class); param.forEach((key, value) -> System.out.println(value)); ``` ``` [] Exception in thread "main" java.lang.ClassCastException: java.lang.String cannot be cast to java.util.List at java.util.LinkedHashMap.forEach(LinkedHashMap.java:684) at org.apache.dolphinscheduler.common.utils.JSONUtils.main(JSONUtils.java:256) ``` I don't find out the deep reason, but I think we should remove this method. **Which version of Dolphin Scheduler:** -[dev]
https://github.com/apache/dolphinscheduler/issues/6072
https://github.com/apache/dolphinscheduler/pull/6283
c855a5926ceb9cfb6efb0c901c8d92fe3774e999
46257834792d3316c9f5ef885f38e069e4eb6452
2021-08-31T10:30:15Z
java
2021-09-23T15:06:53Z
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/model/TaskNode.java
taskParams.put(Constants.CONDITION_RESULT, this.conditionResult); taskParams.put(Constants.DEPENDENCE, this.dependence); taskParams.put(Constants.SWITCH_RESULT, this.switchResult); taskParams.put(Constants.WAIT_START_TIMEOUT, this.waitStartTimeout); return JSONUtils.toJsonString(taskParams); } public Map<String, Object> taskParamsToJsonObj(String taskParams) { Map<String, Object> taskParamsMap = JSONUtils.toMap(taskParams, String.class, Object.class); if (taskParamsMap == null) { taskParamsMap = new HashMap<>(); } return taskParamsMap; } @Override public String toString() { return "TaskNode{" + "id='" + id + '\'' + ", code=" + code + ", version=" + version + ", name='" + name + '\'' + ", desc='" + desc + '\'' + ", type='" + type + '\'' + ", runFlag='" + runFlag + '\'' + ", loc='" + loc + '\'' + ", maxRetryTimes=" + maxRetryTimes + ", retryInterval=" + retryInterval + ", params='" + params + '\'' + ", preTasks='" + preTasks + '\'' + ", preTaskNodeList=" + preTaskNodeList + ", extras='" + extras + '\''
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,072
[Bug][common] Generics type is invalid in JsonUtils.toMap
**Describe the bug** This method is hope to deserialize a JSON to Map. https://github.com/apache/dolphinscheduler/blob/e866d1be86464d812551e8c38ba60767a204c82e/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/JSONUtils.java#L249-L251 But the generics type in the Map is not what we expected. We can write a simple test case: ```java String sqlResult = "{\"id\":[],\"test1\":\"6\"}"; Map<String, List> param = toMap(sqlResult, String.class, List.class); System.out.println(param); ``` It will execute success, and print ``` {id=[], test1=6} ``` The value type of `id` is `List`, the value type of `test1` is `String`. But If we loop the map, it will throw a exception, because the value in this map has different type ```java String sqlResult = "{\"id\":[],\"test1\":\"6\"}"; Map<String, List> param = toMap(sqlResult, String.class, List.class); param.forEach((key, value) -> System.out.println(value)); ``` ``` [] Exception in thread "main" java.lang.ClassCastException: java.lang.String cannot be cast to java.util.List at java.util.LinkedHashMap.forEach(LinkedHashMap.java:684) at org.apache.dolphinscheduler.common.utils.JSONUtils.main(JSONUtils.java:256) ``` I don't find out the deep reason, but I think we should remove this method. **Which version of Dolphin Scheduler:** -[dev]
https://github.com/apache/dolphinscheduler/issues/6072
https://github.com/apache/dolphinscheduler/pull/6283
c855a5926ceb9cfb6efb0c901c8d92fe3774e999
46257834792d3316c9f5ef885f38e069e4eb6452
2021-08-31T10:30:15Z
java
2021-09-23T15:06:53Z
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/model/TaskNode.java
+ ", depList=" + depList + ", dependence='" + dependence + '\'' + ", conditionResult='" + conditionResult + '\'' + ", taskInstancePriority=" + taskInstancePriority + ", workerGroup='" + workerGroup + '\'' + ", environmentCode=" + environmentCode + ", timeout='" + timeout + '\'' + ", delayTime=" + delayTime + '}'; } public void setEnvironmentCode(Long environmentCode) { this.environmentCode = environmentCode; } public Long getEnvironmentCode() { return this.environmentCode; } public String getSwitchResult() { return switchResult; } public void setSwitchResult(String switchResult) { this.switchResult = switchResult; } public String getWaitStartTimeout() { return this.waitStartTimeout; } public void setWaitStartTimeout(String waitStartTimeout) { this.waitStartTimeout = waitStartTimeout; } }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,072
[Bug][common] Generics type is invalid in JsonUtils.toMap
**Describe the bug** This method is hope to deserialize a JSON to Map. https://github.com/apache/dolphinscheduler/blob/e866d1be86464d812551e8c38ba60767a204c82e/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/JSONUtils.java#L249-L251 But the generics type in the Map is not what we expected. We can write a simple test case: ```java String sqlResult = "{\"id\":[],\"test1\":\"6\"}"; Map<String, List> param = toMap(sqlResult, String.class, List.class); System.out.println(param); ``` It will execute success, and print ``` {id=[], test1=6} ``` The value type of `id` is `List`, the value type of `test1` is `String`. But If we loop the map, it will throw a exception, because the value in this map has different type ```java String sqlResult = "{\"id\":[],\"test1\":\"6\"}"; Map<String, List> param = toMap(sqlResult, String.class, List.class); param.forEach((key, value) -> System.out.println(value)); ``` ``` [] Exception in thread "main" java.lang.ClassCastException: java.lang.String cannot be cast to java.util.List at java.util.LinkedHashMap.forEach(LinkedHashMap.java:684) at org.apache.dolphinscheduler.common.utils.JSONUtils.main(JSONUtils.java:256) ``` I don't find out the deep reason, but I think we should remove this method. **Which version of Dolphin Scheduler:** -[dev]
https://github.com/apache/dolphinscheduler/issues/6072
https://github.com/apache/dolphinscheduler/pull/6283
c855a5926ceb9cfb6efb0c901c8d92fe3774e999
46257834792d3316c9f5ef885f38e069e4eb6452
2021-08-31T10:30:15Z
java
2021-09-23T15:06:53Z
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/JSONUtils.java
/* * 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.dolphinscheduler.common.utils; import static java.nio.charset.StandardCharsets.UTF_8; import static com.fasterxml.jackson.databind.DeserializationFeature.ACCEPT_EMPTY_ARRAY_AS_NULL_OBJECT; import static com.fasterxml.jackson.databind.DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES; import static com.fasterxml.jackson.databind.DeserializationFeature.READ_UNKNOWN_ENUM_VALUES_AS_NULL;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,072
[Bug][common] Generics type is invalid in JsonUtils.toMap
**Describe the bug** This method is hope to deserialize a JSON to Map. https://github.com/apache/dolphinscheduler/blob/e866d1be86464d812551e8c38ba60767a204c82e/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/JSONUtils.java#L249-L251 But the generics type in the Map is not what we expected. We can write a simple test case: ```java String sqlResult = "{\"id\":[],\"test1\":\"6\"}"; Map<String, List> param = toMap(sqlResult, String.class, List.class); System.out.println(param); ``` It will execute success, and print ``` {id=[], test1=6} ``` The value type of `id` is `List`, the value type of `test1` is `String`. But If we loop the map, it will throw a exception, because the value in this map has different type ```java String sqlResult = "{\"id\":[],\"test1\":\"6\"}"; Map<String, List> param = toMap(sqlResult, String.class, List.class); param.forEach((key, value) -> System.out.println(value)); ``` ``` [] Exception in thread "main" java.lang.ClassCastException: java.lang.String cannot be cast to java.util.List at java.util.LinkedHashMap.forEach(LinkedHashMap.java:684) at org.apache.dolphinscheduler.common.utils.JSONUtils.main(JSONUtils.java:256) ``` I don't find out the deep reason, but I think we should remove this method. **Which version of Dolphin Scheduler:** -[dev]
https://github.com/apache/dolphinscheduler/issues/6072
https://github.com/apache/dolphinscheduler/pull/6283
c855a5926ceb9cfb6efb0c901c8d92fe3774e999
46257834792d3316c9f5ef885f38e069e4eb6452
2021-08-31T10:30:15Z
java
2021-09-23T15:06:53Z
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/JSONUtils.java
import static com.fasterxml.jackson.databind.MapperFeature.REQUIRE_SETTERS_FOR_GETTERS; import org.apache.commons.lang.StringUtils; import java.io.IOException; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Map; import java.util.TimeZone; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.DeserializationContext; import com.fasterxml.jackson.databind.JsonDeserializer; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.JsonSerializer; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectWriter; import com.fasterxml.jackson.databind.SerializationFeature; import com.fasterxml.jackson.databind.SerializerProvider; import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.ObjectNode; import com.fasterxml.jackson.databind.node.TextNode; import com.fasterxml.jackson.databind.type.CollectionType; /** * json utils */ public class JSONUtils {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,072
[Bug][common] Generics type is invalid in JsonUtils.toMap
**Describe the bug** This method is hope to deserialize a JSON to Map. https://github.com/apache/dolphinscheduler/blob/e866d1be86464d812551e8c38ba60767a204c82e/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/JSONUtils.java#L249-L251 But the generics type in the Map is not what we expected. We can write a simple test case: ```java String sqlResult = "{\"id\":[],\"test1\":\"6\"}"; Map<String, List> param = toMap(sqlResult, String.class, List.class); System.out.println(param); ``` It will execute success, and print ``` {id=[], test1=6} ``` The value type of `id` is `List`, the value type of `test1` is `String`. But If we loop the map, it will throw a exception, because the value in this map has different type ```java String sqlResult = "{\"id\":[],\"test1\":\"6\"}"; Map<String, List> param = toMap(sqlResult, String.class, List.class); param.forEach((key, value) -> System.out.println(value)); ``` ``` [] Exception in thread "main" java.lang.ClassCastException: java.lang.String cannot be cast to java.util.List at java.util.LinkedHashMap.forEach(LinkedHashMap.java:684) at org.apache.dolphinscheduler.common.utils.JSONUtils.main(JSONUtils.java:256) ``` I don't find out the deep reason, but I think we should remove this method. **Which version of Dolphin Scheduler:** -[dev]
https://github.com/apache/dolphinscheduler/issues/6072
https://github.com/apache/dolphinscheduler/pull/6283
c855a5926ceb9cfb6efb0c901c8d92fe3774e999
46257834792d3316c9f5ef885f38e069e4eb6452
2021-08-31T10:30:15Z
java
2021-09-23T15:06:53Z
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/JSONUtils.java
private static final Logger logger = LoggerFactory.getLogger(JSONUtils.class); /** * can use static singleton, inject: just make sure to reuse! */ private static final ObjectMapper objectMapper = new ObjectMapper() .configure(FAIL_ON_UNKNOWN_PROPERTIES, false) .configure(ACCEPT_EMPTY_ARRAY_AS_NULL_OBJECT, true) .configure(READ_UNKNOWN_ENUM_VALUES_AS_NULL, true) .configure(REQUIRE_SETTERS_FOR_GETTERS, true) .setTimeZone(TimeZone.getDefault()); private JSONUtils() { throw new UnsupportedOperationException("Construct JSONUtils"); } public static ArrayNode createArrayNode() { return objectMapper.createArrayNode(); } public static ObjectNode createObjectNode() { return objectMapper.createObjectNode(); } public static JsonNode toJsonNode(Object obj) { return objectMapper.valueToTree(obj); } /** * json representation of object
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,072
[Bug][common] Generics type is invalid in JsonUtils.toMap
**Describe the bug** This method is hope to deserialize a JSON to Map. https://github.com/apache/dolphinscheduler/blob/e866d1be86464d812551e8c38ba60767a204c82e/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/JSONUtils.java#L249-L251 But the generics type in the Map is not what we expected. We can write a simple test case: ```java String sqlResult = "{\"id\":[],\"test1\":\"6\"}"; Map<String, List> param = toMap(sqlResult, String.class, List.class); System.out.println(param); ``` It will execute success, and print ``` {id=[], test1=6} ``` The value type of `id` is `List`, the value type of `test1` is `String`. But If we loop the map, it will throw a exception, because the value in this map has different type ```java String sqlResult = "{\"id\":[],\"test1\":\"6\"}"; Map<String, List> param = toMap(sqlResult, String.class, List.class); param.forEach((key, value) -> System.out.println(value)); ``` ``` [] Exception in thread "main" java.lang.ClassCastException: java.lang.String cannot be cast to java.util.List at java.util.LinkedHashMap.forEach(LinkedHashMap.java:684) at org.apache.dolphinscheduler.common.utils.JSONUtils.main(JSONUtils.java:256) ``` I don't find out the deep reason, but I think we should remove this method. **Which version of Dolphin Scheduler:** -[dev]
https://github.com/apache/dolphinscheduler/issues/6072
https://github.com/apache/dolphinscheduler/pull/6283
c855a5926ceb9cfb6efb0c901c8d92fe3774e999
46257834792d3316c9f5ef885f38e069e4eb6452
2021-08-31T10:30:15Z
java
2021-09-23T15:06:53Z
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/JSONUtils.java
* * @param object object * @param feature feature * @return object to json string */ public static String toJsonString(Object object, SerializationFeature feature) { try { ObjectWriter writer = objectMapper.writer(feature); return writer.writeValueAsString(object); } catch (Exception e) { logger.error("object to json exception!", e); } return null; } /** * This method deserializes the specified Json into an object of the specified class. It is not * suitable to use if the specified class is a generic type since it will not have the generic * type information because of the Type Erasure feature of Java. Therefore, this method should not * be used if the desired type is a generic type. Note that this method works fine if the any of * the fields of the specified object are generics, just the object itself should not be a * generic type. * * @param json the string from which the object is to be deserialized * @param clazz the class of T * @param <T> T * @return an object of type T from the string * classOfT */ public static <T> T parseObject(String json, Class<T> clazz) { if (StringUtils.isEmpty(json)) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,072
[Bug][common] Generics type is invalid in JsonUtils.toMap
**Describe the bug** This method is hope to deserialize a JSON to Map. https://github.com/apache/dolphinscheduler/blob/e866d1be86464d812551e8c38ba60767a204c82e/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/JSONUtils.java#L249-L251 But the generics type in the Map is not what we expected. We can write a simple test case: ```java String sqlResult = "{\"id\":[],\"test1\":\"6\"}"; Map<String, List> param = toMap(sqlResult, String.class, List.class); System.out.println(param); ``` It will execute success, and print ``` {id=[], test1=6} ``` The value type of `id` is `List`, the value type of `test1` is `String`. But If we loop the map, it will throw a exception, because the value in this map has different type ```java String sqlResult = "{\"id\":[],\"test1\":\"6\"}"; Map<String, List> param = toMap(sqlResult, String.class, List.class); param.forEach((key, value) -> System.out.println(value)); ``` ``` [] Exception in thread "main" java.lang.ClassCastException: java.lang.String cannot be cast to java.util.List at java.util.LinkedHashMap.forEach(LinkedHashMap.java:684) at org.apache.dolphinscheduler.common.utils.JSONUtils.main(JSONUtils.java:256) ``` I don't find out the deep reason, but I think we should remove this method. **Which version of Dolphin Scheduler:** -[dev]
https://github.com/apache/dolphinscheduler/issues/6072
https://github.com/apache/dolphinscheduler/pull/6283
c855a5926ceb9cfb6efb0c901c8d92fe3774e999
46257834792d3316c9f5ef885f38e069e4eb6452
2021-08-31T10:30:15Z
java
2021-09-23T15:06:53Z
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/JSONUtils.java
return null; } try { return objectMapper.readValue(json, clazz); } catch (Exception e) { logger.error("parse object exception!", e); } return null; } /** * deserialize * * @param src byte array * @param clazz class * @param <T> deserialize type * @return deserialize type */ public static <T> T parseObject(byte[] src, Class<T> clazz) { if (src == null) { return null; } String json = new String(src, UTF_8); return parseObject(json, clazz); } /** * json to list * * @param json json string * @param clazz class * @param <T> T
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,072
[Bug][common] Generics type is invalid in JsonUtils.toMap
**Describe the bug** This method is hope to deserialize a JSON to Map. https://github.com/apache/dolphinscheduler/blob/e866d1be86464d812551e8c38ba60767a204c82e/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/JSONUtils.java#L249-L251 But the generics type in the Map is not what we expected. We can write a simple test case: ```java String sqlResult = "{\"id\":[],\"test1\":\"6\"}"; Map<String, List> param = toMap(sqlResult, String.class, List.class); System.out.println(param); ``` It will execute success, and print ``` {id=[], test1=6} ``` The value type of `id` is `List`, the value type of `test1` is `String`. But If we loop the map, it will throw a exception, because the value in this map has different type ```java String sqlResult = "{\"id\":[],\"test1\":\"6\"}"; Map<String, List> param = toMap(sqlResult, String.class, List.class); param.forEach((key, value) -> System.out.println(value)); ``` ``` [] Exception in thread "main" java.lang.ClassCastException: java.lang.String cannot be cast to java.util.List at java.util.LinkedHashMap.forEach(LinkedHashMap.java:684) at org.apache.dolphinscheduler.common.utils.JSONUtils.main(JSONUtils.java:256) ``` I don't find out the deep reason, but I think we should remove this method. **Which version of Dolphin Scheduler:** -[dev]
https://github.com/apache/dolphinscheduler/issues/6072
https://github.com/apache/dolphinscheduler/pull/6283
c855a5926ceb9cfb6efb0c901c8d92fe3774e999
46257834792d3316c9f5ef885f38e069e4eb6452
2021-08-31T10:30:15Z
java
2021-09-23T15:06:53Z
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/JSONUtils.java
* @return list */ public static <T> List<T> toList(String json, Class<T> clazz) { if (StringUtils.isEmpty(json)) { return Collections.emptyList(); } try { CollectionType listType = objectMapper.getTypeFactory().constructCollectionType(ArrayList.class, clazz); return objectMapper.readValue(json, listType); } catch (Exception e) { logger.error("parse list exception!", e); } return Collections.emptyList(); } /** * check json object valid * * @param json json * @return true if valid */ public static boolean checkJsonValid(String json) { if (StringUtils.isEmpty(json)) { return false; } try { objectMapper.readTree(json); return true; } catch (IOException e) { logger.error("check json object valid exception!", e); }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,072
[Bug][common] Generics type is invalid in JsonUtils.toMap
**Describe the bug** This method is hope to deserialize a JSON to Map. https://github.com/apache/dolphinscheduler/blob/e866d1be86464d812551e8c38ba60767a204c82e/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/JSONUtils.java#L249-L251 But the generics type in the Map is not what we expected. We can write a simple test case: ```java String sqlResult = "{\"id\":[],\"test1\":\"6\"}"; Map<String, List> param = toMap(sqlResult, String.class, List.class); System.out.println(param); ``` It will execute success, and print ``` {id=[], test1=6} ``` The value type of `id` is `List`, the value type of `test1` is `String`. But If we loop the map, it will throw a exception, because the value in this map has different type ```java String sqlResult = "{\"id\":[],\"test1\":\"6\"}"; Map<String, List> param = toMap(sqlResult, String.class, List.class); param.forEach((key, value) -> System.out.println(value)); ``` ``` [] Exception in thread "main" java.lang.ClassCastException: java.lang.String cannot be cast to java.util.List at java.util.LinkedHashMap.forEach(LinkedHashMap.java:684) at org.apache.dolphinscheduler.common.utils.JSONUtils.main(JSONUtils.java:256) ``` I don't find out the deep reason, but I think we should remove this method. **Which version of Dolphin Scheduler:** -[dev]
https://github.com/apache/dolphinscheduler/issues/6072
https://github.com/apache/dolphinscheduler/pull/6283
c855a5926ceb9cfb6efb0c901c8d92fe3774e999
46257834792d3316c9f5ef885f38e069e4eb6452
2021-08-31T10:30:15Z
java
2021-09-23T15:06:53Z
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/JSONUtils.java
return false; } /** * Method for finding a JSON Object field with specified name in this * node or its child nodes, and returning value it has. * If no matching field is found in this node or its descendants, returns null. * * @param jsonNode json node * @param fieldName Name of field to look for * @return Value of first matching node found, if any; null if none */ public static String findValue(JsonNode jsonNode, String fieldName) { JsonNode node = jsonNode.findValue(fieldName); if (node == null) { return null; } return node.asText(); } /** * json to map * {@link #toMap(String, Class, Class)} * * @param json json * @return json to map */ public static Map<String, String> toMap(String json) { return parseObject(json, new TypeReference<Map<String, String>>() {}); } /** * from the key-value generated json to get the str value no matter the real type of value
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,072
[Bug][common] Generics type is invalid in JsonUtils.toMap
**Describe the bug** This method is hope to deserialize a JSON to Map. https://github.com/apache/dolphinscheduler/blob/e866d1be86464d812551e8c38ba60767a204c82e/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/JSONUtils.java#L249-L251 But the generics type in the Map is not what we expected. We can write a simple test case: ```java String sqlResult = "{\"id\":[],\"test1\":\"6\"}"; Map<String, List> param = toMap(sqlResult, String.class, List.class); System.out.println(param); ``` It will execute success, and print ``` {id=[], test1=6} ``` The value type of `id` is `List`, the value type of `test1` is `String`. But If we loop the map, it will throw a exception, because the value in this map has different type ```java String sqlResult = "{\"id\":[],\"test1\":\"6\"}"; Map<String, List> param = toMap(sqlResult, String.class, List.class); param.forEach((key, value) -> System.out.println(value)); ``` ``` [] Exception in thread "main" java.lang.ClassCastException: java.lang.String cannot be cast to java.util.List at java.util.LinkedHashMap.forEach(LinkedHashMap.java:684) at org.apache.dolphinscheduler.common.utils.JSONUtils.main(JSONUtils.java:256) ``` I don't find out the deep reason, but I think we should remove this method. **Which version of Dolphin Scheduler:** -[dev]
https://github.com/apache/dolphinscheduler/issues/6072
https://github.com/apache/dolphinscheduler/pull/6283
c855a5926ceb9cfb6efb0c901c8d92fe3774e999
46257834792d3316c9f5ef885f38e069e4eb6452
2021-08-31T10:30:15Z
java
2021-09-23T15:06:53Z
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/JSONUtils.java
* @param json the json str * @param nodeName key * @return the str value of key */ public static String getNodeString(String json, String nodeName) { try { JsonNode rootNode = objectMapper.readTree(json); return rootNode.has(nodeName) ? rootNode.get(nodeName).toString() : ""; } catch (JsonProcessingException e) { return ""; } } /** * json to map * * @param json json * @param classK classK * @param classV classV * @param <K> K * @param <V> V * @return to map */ public static <K, V> Map<K, V> toMap(String json, Class<K> classK, Class<V> classV) { return parseObject(json, new TypeReference<Map<K, V>>() {}); } /** * json to object * * @param json json string
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,072
[Bug][common] Generics type is invalid in JsonUtils.toMap
**Describe the bug** This method is hope to deserialize a JSON to Map. https://github.com/apache/dolphinscheduler/blob/e866d1be86464d812551e8c38ba60767a204c82e/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/JSONUtils.java#L249-L251 But the generics type in the Map is not what we expected. We can write a simple test case: ```java String sqlResult = "{\"id\":[],\"test1\":\"6\"}"; Map<String, List> param = toMap(sqlResult, String.class, List.class); System.out.println(param); ``` It will execute success, and print ``` {id=[], test1=6} ``` The value type of `id` is `List`, the value type of `test1` is `String`. But If we loop the map, it will throw a exception, because the value in this map has different type ```java String sqlResult = "{\"id\":[],\"test1\":\"6\"}"; Map<String, List> param = toMap(sqlResult, String.class, List.class); param.forEach((key, value) -> System.out.println(value)); ``` ``` [] Exception in thread "main" java.lang.ClassCastException: java.lang.String cannot be cast to java.util.List at java.util.LinkedHashMap.forEach(LinkedHashMap.java:684) at org.apache.dolphinscheduler.common.utils.JSONUtils.main(JSONUtils.java:256) ``` I don't find out the deep reason, but I think we should remove this method. **Which version of Dolphin Scheduler:** -[dev]
https://github.com/apache/dolphinscheduler/issues/6072
https://github.com/apache/dolphinscheduler/pull/6283
c855a5926ceb9cfb6efb0c901c8d92fe3774e999
46257834792d3316c9f5ef885f38e069e4eb6452
2021-08-31T10:30:15Z
java
2021-09-23T15:06:53Z
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/JSONUtils.java
* @param type type reference * @param <T> * @return return parse object */ public static <T> T parseObject(String json, TypeReference<T> type) { if (StringUtils.isEmpty(json)) { return null; } try { return objectMapper.readValue(json, type); } catch (Exception e) { logger.error("json to map exception!", e); } return null; } /** * object to json string * * @param object object * @return json string */ public static String toJsonString(Object object) { try { return objectMapper.writeValueAsString(object); } catch (Exception e) { throw new RuntimeException("Object json deserialization exception.", e); } } /** * serialize to json byte
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,072
[Bug][common] Generics type is invalid in JsonUtils.toMap
**Describe the bug** This method is hope to deserialize a JSON to Map. https://github.com/apache/dolphinscheduler/blob/e866d1be86464d812551e8c38ba60767a204c82e/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/JSONUtils.java#L249-L251 But the generics type in the Map is not what we expected. We can write a simple test case: ```java String sqlResult = "{\"id\":[],\"test1\":\"6\"}"; Map<String, List> param = toMap(sqlResult, String.class, List.class); System.out.println(param); ``` It will execute success, and print ``` {id=[], test1=6} ``` The value type of `id` is `List`, the value type of `test1` is `String`. But If we loop the map, it will throw a exception, because the value in this map has different type ```java String sqlResult = "{\"id\":[],\"test1\":\"6\"}"; Map<String, List> param = toMap(sqlResult, String.class, List.class); param.forEach((key, value) -> System.out.println(value)); ``` ``` [] Exception in thread "main" java.lang.ClassCastException: java.lang.String cannot be cast to java.util.List at java.util.LinkedHashMap.forEach(LinkedHashMap.java:684) at org.apache.dolphinscheduler.common.utils.JSONUtils.main(JSONUtils.java:256) ``` I don't find out the deep reason, but I think we should remove this method. **Which version of Dolphin Scheduler:** -[dev]
https://github.com/apache/dolphinscheduler/issues/6072
https://github.com/apache/dolphinscheduler/pull/6283
c855a5926ceb9cfb6efb0c901c8d92fe3774e999
46257834792d3316c9f5ef885f38e069e4eb6452
2021-08-31T10:30:15Z
java
2021-09-23T15:06:53Z
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/JSONUtils.java
* * @param obj object * @param <T> object type * @return byte array */ public static <T> byte[] toJsonByteArray(T obj) { if (obj == null) { return null; } String json = ""; try { json = toJsonString(obj); } catch (Exception e) { logger.error("json serialize exception.", e); } return json.getBytes(UTF_8); } public static ObjectNode parseObject(String text) { try { if (text.isEmpty()) { return parseObject(text, ObjectNode.class); } else { return (ObjectNode) objectMapper.readTree(text); } } catch (Exception e) { throw new RuntimeException("String json deserialization exception.", e); } } public static ArrayNode parseArray(String text) { try {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,072
[Bug][common] Generics type is invalid in JsonUtils.toMap
**Describe the bug** This method is hope to deserialize a JSON to Map. https://github.com/apache/dolphinscheduler/blob/e866d1be86464d812551e8c38ba60767a204c82e/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/JSONUtils.java#L249-L251 But the generics type in the Map is not what we expected. We can write a simple test case: ```java String sqlResult = "{\"id\":[],\"test1\":\"6\"}"; Map<String, List> param = toMap(sqlResult, String.class, List.class); System.out.println(param); ``` It will execute success, and print ``` {id=[], test1=6} ``` The value type of `id` is `List`, the value type of `test1` is `String`. But If we loop the map, it will throw a exception, because the value in this map has different type ```java String sqlResult = "{\"id\":[],\"test1\":\"6\"}"; Map<String, List> param = toMap(sqlResult, String.class, List.class); param.forEach((key, value) -> System.out.println(value)); ``` ``` [] Exception in thread "main" java.lang.ClassCastException: java.lang.String cannot be cast to java.util.List at java.util.LinkedHashMap.forEach(LinkedHashMap.java:684) at org.apache.dolphinscheduler.common.utils.JSONUtils.main(JSONUtils.java:256) ``` I don't find out the deep reason, but I think we should remove this method. **Which version of Dolphin Scheduler:** -[dev]
https://github.com/apache/dolphinscheduler/issues/6072
https://github.com/apache/dolphinscheduler/pull/6283
c855a5926ceb9cfb6efb0c901c8d92fe3774e999
46257834792d3316c9f5ef885f38e069e4eb6452
2021-08-31T10:30:15Z
java
2021-09-23T15:06:53Z
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/JSONUtils.java
return (ArrayNode) objectMapper.readTree(text); } catch (Exception e) { throw new RuntimeException("Json deserialization exception.", e); } } /** * json serializer */ public static class JsonDataSerializer extends JsonSerializer<String> { @Override public void serialize(String value, JsonGenerator gen, SerializerProvider provider) throws IOException { gen.writeRawValue(value); } } /** * json data deserializer */ public static class JsonDataDeserializer extends JsonDeserializer<String> { @Override public String deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { JsonNode node = p.getCodec().readTree(p); if (node instanceof TextNode) { return node.asText(); } else { return node.toString(); } } } }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,072
[Bug][common] Generics type is invalid in JsonUtils.toMap
**Describe the bug** This method is hope to deserialize a JSON to Map. https://github.com/apache/dolphinscheduler/blob/e866d1be86464d812551e8c38ba60767a204c82e/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/JSONUtils.java#L249-L251 But the generics type in the Map is not what we expected. We can write a simple test case: ```java String sqlResult = "{\"id\":[],\"test1\":\"6\"}"; Map<String, List> param = toMap(sqlResult, String.class, List.class); System.out.println(param); ``` It will execute success, and print ``` {id=[], test1=6} ``` The value type of `id` is `List`, the value type of `test1` is `String`. But If we loop the map, it will throw a exception, because the value in this map has different type ```java String sqlResult = "{\"id\":[],\"test1\":\"6\"}"; Map<String, List> param = toMap(sqlResult, String.class, List.class); param.forEach((key, value) -> System.out.println(value)); ``` ``` [] Exception in thread "main" java.lang.ClassCastException: java.lang.String cannot be cast to java.util.List at java.util.LinkedHashMap.forEach(LinkedHashMap.java:684) at org.apache.dolphinscheduler.common.utils.JSONUtils.main(JSONUtils.java:256) ``` I don't find out the deep reason, but I think we should remove this method. **Which version of Dolphin Scheduler:** -[dev]
https://github.com/apache/dolphinscheduler/issues/6072
https://github.com/apache/dolphinscheduler/pull/6283
c855a5926ceb9cfb6efb0c901c8d92fe3774e999
46257834792d3316c9f5ef885f38e069e4eb6452
2021-08-31T10:30:15Z
java
2021-09-23T15:06:53Z
dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/utils/JSONUtilsTest.java
/* * 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.
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,072
[Bug][common] Generics type is invalid in JsonUtils.toMap
**Describe the bug** This method is hope to deserialize a JSON to Map. https://github.com/apache/dolphinscheduler/blob/e866d1be86464d812551e8c38ba60767a204c82e/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/JSONUtils.java#L249-L251 But the generics type in the Map is not what we expected. We can write a simple test case: ```java String sqlResult = "{\"id\":[],\"test1\":\"6\"}"; Map<String, List> param = toMap(sqlResult, String.class, List.class); System.out.println(param); ``` It will execute success, and print ``` {id=[], test1=6} ``` The value type of `id` is `List`, the value type of `test1` is `String`. But If we loop the map, it will throw a exception, because the value in this map has different type ```java String sqlResult = "{\"id\":[],\"test1\":\"6\"}"; Map<String, List> param = toMap(sqlResult, String.class, List.class); param.forEach((key, value) -> System.out.println(value)); ``` ``` [] Exception in thread "main" java.lang.ClassCastException: java.lang.String cannot be cast to java.util.List at java.util.LinkedHashMap.forEach(LinkedHashMap.java:684) at org.apache.dolphinscheduler.common.utils.JSONUtils.main(JSONUtils.java:256) ``` I don't find out the deep reason, but I think we should remove this method. **Which version of Dolphin Scheduler:** -[dev]
https://github.com/apache/dolphinscheduler/issues/6072
https://github.com/apache/dolphinscheduler/pull/6283
c855a5926ceb9cfb6efb0c901c8d92fe3774e999
46257834792d3316c9f5ef885f38e069e4eb6452
2021-08-31T10:30:15Z
java
2021-09-23T15:06:53Z
dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/utils/JSONUtilsTest.java
* 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.dolphinscheduler.common.utils; import org.apache.dolphinscheduler.common.enums.DataType; import org.apache.dolphinscheduler.common.enums.Direct; import org.apache.dolphinscheduler.common.model.TaskNode; import org.apache.dolphinscheduler.common.process.Property; import java.util.ArrayList; import java.util.HashMap; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import org.junit.Assert; import org.junit.Test; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.SerializationFeature; import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.JsonNodeFactory; import com.fasterxml.jackson.databind.node.ObjectNode; public class JSONUtilsTest {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,072
[Bug][common] Generics type is invalid in JsonUtils.toMap
**Describe the bug** This method is hope to deserialize a JSON to Map. https://github.com/apache/dolphinscheduler/blob/e866d1be86464d812551e8c38ba60767a204c82e/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/JSONUtils.java#L249-L251 But the generics type in the Map is not what we expected. We can write a simple test case: ```java String sqlResult = "{\"id\":[],\"test1\":\"6\"}"; Map<String, List> param = toMap(sqlResult, String.class, List.class); System.out.println(param); ``` It will execute success, and print ``` {id=[], test1=6} ``` The value type of `id` is `List`, the value type of `test1` is `String`. But If we loop the map, it will throw a exception, because the value in this map has different type ```java String sqlResult = "{\"id\":[],\"test1\":\"6\"}"; Map<String, List> param = toMap(sqlResult, String.class, List.class); param.forEach((key, value) -> System.out.println(value)); ``` ``` [] Exception in thread "main" java.lang.ClassCastException: java.lang.String cannot be cast to java.util.List at java.util.LinkedHashMap.forEach(LinkedHashMap.java:684) at org.apache.dolphinscheduler.common.utils.JSONUtils.main(JSONUtils.java:256) ``` I don't find out the deep reason, but I think we should remove this method. **Which version of Dolphin Scheduler:** -[dev]
https://github.com/apache/dolphinscheduler/issues/6072
https://github.com/apache/dolphinscheduler/pull/6283
c855a5926ceb9cfb6efb0c901c8d92fe3774e999
46257834792d3316c9f5ef885f38e069e4eb6452
2021-08-31T10:30:15Z
java
2021-09-23T15:06:53Z
dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/utils/JSONUtilsTest.java
@Test public void createArrayNodeTest() { Property property = new Property(); property.setProp("ds"); property.setDirect(Direct.IN); property.setType(DataType.VARCHAR); property.setValue("sssssss"); String str = "[{\"prop\":\"ds\",\"direct\":\"IN\",\"type\":\"VARCHAR\",\"value\":\"sssssss\"},{\"prop\":\"ds\",\"direct\":\"IN\",\"type\":\"VARCHAR\",\"value\":\"sssssss\"}]"; JsonNode jsonNode = JSONUtils.toJsonNode(property); ArrayNode arrayNode = JSONUtils.createArrayNode(); ArrayList<JsonNode> objects = new ArrayList<>(); objects.add(jsonNode); objects.add(jsonNode); ArrayNode jsonNodes = arrayNode.addAll(objects); String s = JSONUtils.toJsonString(jsonNodes); Assert.assertEquals(s, str); } @Test public void toJsonNodeTest() { Property property = new Property(); property.setProp("ds"); property.setDirect(Direct.IN); property.setType(DataType.VARCHAR); property.setValue("sssssss"); String str = "{\"prop\":\"ds\",\"direct\":\"IN\",\"type\":\"VARCHAR\",\"value\":\"sssssss\"}"; JsonNode jsonNodes = JSONUtils.toJsonNode(property); String s = JSONUtils.toJsonString(jsonNodes); Assert.assertEquals(s, str); }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,072
[Bug][common] Generics type is invalid in JsonUtils.toMap
**Describe the bug** This method is hope to deserialize a JSON to Map. https://github.com/apache/dolphinscheduler/blob/e866d1be86464d812551e8c38ba60767a204c82e/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/JSONUtils.java#L249-L251 But the generics type in the Map is not what we expected. We can write a simple test case: ```java String sqlResult = "{\"id\":[],\"test1\":\"6\"}"; Map<String, List> param = toMap(sqlResult, String.class, List.class); System.out.println(param); ``` It will execute success, and print ``` {id=[], test1=6} ``` The value type of `id` is `List`, the value type of `test1` is `String`. But If we loop the map, it will throw a exception, because the value in this map has different type ```java String sqlResult = "{\"id\":[],\"test1\":\"6\"}"; Map<String, List> param = toMap(sqlResult, String.class, List.class); param.forEach((key, value) -> System.out.println(value)); ``` ``` [] Exception in thread "main" java.lang.ClassCastException: java.lang.String cannot be cast to java.util.List at java.util.LinkedHashMap.forEach(LinkedHashMap.java:684) at org.apache.dolphinscheduler.common.utils.JSONUtils.main(JSONUtils.java:256) ``` I don't find out the deep reason, but I think we should remove this method. **Which version of Dolphin Scheduler:** -[dev]
https://github.com/apache/dolphinscheduler/issues/6072
https://github.com/apache/dolphinscheduler/pull/6283
c855a5926ceb9cfb6efb0c901c8d92fe3774e999
46257834792d3316c9f5ef885f38e069e4eb6452
2021-08-31T10:30:15Z
java
2021-09-23T15:06:53Z
dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/utils/JSONUtilsTest.java
@Test public void createObjectNodeTest() { String jsonStr = "{\"a\":\"b\",\"b\":\"d\"}"; ObjectNode objectNode = JSONUtils.createObjectNode(); objectNode.put("a","b"); objectNode.put("b","d"); String s = JSONUtils.toJsonString(objectNode); Assert.assertEquals(s, jsonStr); } @Test public void toMap() { String jsonStr = "{\"id\":\"1001\",\"name\":\"Jobs\"}"; Map<String, String> models = JSONUtils.toMap(jsonStr); Assert.assertEquals("1001", models.get("id")); Assert.assertEquals("Jobs", models.get("name")); } @Test public void convert2Property() { Property property = new Property(); property.setProp("ds"); property.setDirect(Direct.IN); property.setType(DataType.VARCHAR); property.setValue("sssssss"); String str = "{\"direct\":\"IN\",\"prop\":\"ds\",\"type\":\"VARCHAR\",\"value\":\"sssssss\"}"; Property property1 = JSONUtils.parseObject(str, Property.class); Direct direct = property1.getDirect(); Assert.assertEquals(Direct.IN, direct); } @Test public void string2MapTest() {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,072
[Bug][common] Generics type is invalid in JsonUtils.toMap
**Describe the bug** This method is hope to deserialize a JSON to Map. https://github.com/apache/dolphinscheduler/blob/e866d1be86464d812551e8c38ba60767a204c82e/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/JSONUtils.java#L249-L251 But the generics type in the Map is not what we expected. We can write a simple test case: ```java String sqlResult = "{\"id\":[],\"test1\":\"6\"}"; Map<String, List> param = toMap(sqlResult, String.class, List.class); System.out.println(param); ``` It will execute success, and print ``` {id=[], test1=6} ``` The value type of `id` is `List`, the value type of `test1` is `String`. But If we loop the map, it will throw a exception, because the value in this map has different type ```java String sqlResult = "{\"id\":[],\"test1\":\"6\"}"; Map<String, List> param = toMap(sqlResult, String.class, List.class); param.forEach((key, value) -> System.out.println(value)); ``` ``` [] Exception in thread "main" java.lang.ClassCastException: java.lang.String cannot be cast to java.util.List at java.util.LinkedHashMap.forEach(LinkedHashMap.java:684) at org.apache.dolphinscheduler.common.utils.JSONUtils.main(JSONUtils.java:256) ``` I don't find out the deep reason, but I think we should remove this method. **Which version of Dolphin Scheduler:** -[dev]
https://github.com/apache/dolphinscheduler/issues/6072
https://github.com/apache/dolphinscheduler/pull/6283
c855a5926ceb9cfb6efb0c901c8d92fe3774e999
46257834792d3316c9f5ef885f38e069e4eb6452
2021-08-31T10:30:15Z
java
2021-09-23T15:06:53Z
dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/utils/JSONUtilsTest.java
String str = list2String(); List<LinkedHashMap> maps = JSONUtils.toList(str, LinkedHashMap.class); Assert.assertEquals(1, maps.size()); Assert.assertEquals("mysql200", maps.get(0).get("mysql service name")); Assert.assertEquals("192.168.xx.xx", maps.get(0).get("mysql address")); Assert.assertEquals("3306", maps.get(0).get("port")); Assert.assertEquals("80", maps.get(0).get("no index of number")); Assert.assertEquals("190", maps.get(0).get("database client connections")); } public String list2String() { LinkedHashMap<String, String> map1 = new LinkedHashMap<>(); map1.put("mysql service name", "mysql200"); map1.put("mysql address", "192.168.xx.xx"); map1.put("port", "3306"); map1.put("no index of number", "80"); map1.put("database client connections", "190"); List<LinkedHashMap<String, String>> maps = new ArrayList<>(); maps.add(0, map1); String resultJson = JSONUtils.toJsonString(maps); return resultJson; } @Test public void testParseObject() { Assert.assertNull(JSONUtils.parseObject("")); Assert.assertNull(JSONUtils.parseObject("foo", String.class)); } @Test public void testNodeString() { Assert.assertEquals("", JSONUtils.getNodeString("", "key"));
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,072
[Bug][common] Generics type is invalid in JsonUtils.toMap
**Describe the bug** This method is hope to deserialize a JSON to Map. https://github.com/apache/dolphinscheduler/blob/e866d1be86464d812551e8c38ba60767a204c82e/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/JSONUtils.java#L249-L251 But the generics type in the Map is not what we expected. We can write a simple test case: ```java String sqlResult = "{\"id\":[],\"test1\":\"6\"}"; Map<String, List> param = toMap(sqlResult, String.class, List.class); System.out.println(param); ``` It will execute success, and print ``` {id=[], test1=6} ``` The value type of `id` is `List`, the value type of `test1` is `String`. But If we loop the map, it will throw a exception, because the value in this map has different type ```java String sqlResult = "{\"id\":[],\"test1\":\"6\"}"; Map<String, List> param = toMap(sqlResult, String.class, List.class); param.forEach((key, value) -> System.out.println(value)); ``` ``` [] Exception in thread "main" java.lang.ClassCastException: java.lang.String cannot be cast to java.util.List at java.util.LinkedHashMap.forEach(LinkedHashMap.java:684) at org.apache.dolphinscheduler.common.utils.JSONUtils.main(JSONUtils.java:256) ``` I don't find out the deep reason, but I think we should remove this method. **Which version of Dolphin Scheduler:** -[dev]
https://github.com/apache/dolphinscheduler/issues/6072
https://github.com/apache/dolphinscheduler/pull/6283
c855a5926ceb9cfb6efb0c901c8d92fe3774e999
46257834792d3316c9f5ef885f38e069e4eb6452
2021-08-31T10:30:15Z
java
2021-09-23T15:06:53Z
dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/utils/JSONUtilsTest.java
Assert.assertEquals("", JSONUtils.getNodeString("abc", "key")); Assert.assertEquals("", JSONUtils.getNodeString("{\"bar\":\"foo\"}", "key")); Assert.assertEquals("\"foo\"", JSONUtils.getNodeString("{\"bar\":\"foo\"}", "bar")); } @Test public void testJsonByteArray() { String str = "foo"; byte[] serializeByte = JSONUtils.toJsonByteArray(str); String deserialize = JSONUtils.parseObject(serializeByte, String.class); Assert.assertEquals(str, deserialize); str = null; serializeByte = JSONUtils.toJsonByteArray(str); deserialize = JSONUtils.parseObject(serializeByte, String.class); Assert.assertNull(deserialize); } @Test public void testToList() { Assert.assertEquals(new ArrayList(), JSONUtils.toList("A1B2C3", null)); Assert.assertEquals(new ArrayList(), JSONUtils.toList("", null)); } @Test public void testCheckJsonValid() { Assert.assertTrue(JSONUtils.checkJsonValid("3")); Assert.assertFalse(JSONUtils.checkJsonValid("")); } @Test public void testFindValue() {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,072
[Bug][common] Generics type is invalid in JsonUtils.toMap
**Describe the bug** This method is hope to deserialize a JSON to Map. https://github.com/apache/dolphinscheduler/blob/e866d1be86464d812551e8c38ba60767a204c82e/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/JSONUtils.java#L249-L251 But the generics type in the Map is not what we expected. We can write a simple test case: ```java String sqlResult = "{\"id\":[],\"test1\":\"6\"}"; Map<String, List> param = toMap(sqlResult, String.class, List.class); System.out.println(param); ``` It will execute success, and print ``` {id=[], test1=6} ``` The value type of `id` is `List`, the value type of `test1` is `String`. But If we loop the map, it will throw a exception, because the value in this map has different type ```java String sqlResult = "{\"id\":[],\"test1\":\"6\"}"; Map<String, List> param = toMap(sqlResult, String.class, List.class); param.forEach((key, value) -> System.out.println(value)); ``` ``` [] Exception in thread "main" java.lang.ClassCastException: java.lang.String cannot be cast to java.util.List at java.util.LinkedHashMap.forEach(LinkedHashMap.java:684) at org.apache.dolphinscheduler.common.utils.JSONUtils.main(JSONUtils.java:256) ``` I don't find out the deep reason, but I think we should remove this method. **Which version of Dolphin Scheduler:** -[dev]
https://github.com/apache/dolphinscheduler/issues/6072
https://github.com/apache/dolphinscheduler/pull/6283
c855a5926ceb9cfb6efb0c901c8d92fe3774e999
46257834792d3316c9f5ef885f38e069e4eb6452
2021-08-31T10:30:15Z
java
2021-09-23T15:06:53Z
dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/utils/JSONUtilsTest.java
Assert.assertNull(JSONUtils.findValue( new ArrayNode(new JsonNodeFactory(true)), null)); } @Test public void testToMap() { Map<String, String> map = new HashMap<>(); map.put("foo", "bar"); Assert.assertTrue(map.equals(JSONUtils.toMap( "{\n" + "\"foo\": \"bar\"\n" + "}"))); Assert.assertFalse(map.equals(JSONUtils.toMap( "{\n" + "\"bar\": \"foo\"\n" + "}"))); Assert.assertNull(JSONUtils.toMap("3")); Assert.assertNull(JSONUtils.toMap(null)); Assert.assertNull(JSONUtils.toMap("3", null, null)); Assert.assertNull(JSONUtils.toMap(null, null, null)); String str = "{\"resourceList\":[],\"localParams\":[],\"rawScript\":\"#!/bin/bash\\necho \\\"shell-1\\\"\"}"; Map<String, String> m = JSONUtils.toMap(str); Assert.assertNotNull(m); } @Test public void testToJsonString() { Map<String, Object> map = new HashMap<>(); map.put("foo", "bar"); Assert.assertEquals("{\"foo\":\"bar\"}", JSONUtils.toJsonString(map)); Assert.assertEquals(String.valueOf((Object) null), JSONUtils.toJsonString(null)); Assert.assertEquals("{\"foo\":\"bar\"}", JSONUtils.toJsonString(map, SerializationFeature.WRITE_NULL_MAP_VALUES)); }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,072
[Bug][common] Generics type is invalid in JsonUtils.toMap
**Describe the bug** This method is hope to deserialize a JSON to Map. https://github.com/apache/dolphinscheduler/blob/e866d1be86464d812551e8c38ba60767a204c82e/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/JSONUtils.java#L249-L251 But the generics type in the Map is not what we expected. We can write a simple test case: ```java String sqlResult = "{\"id\":[],\"test1\":\"6\"}"; Map<String, List> param = toMap(sqlResult, String.class, List.class); System.out.println(param); ``` It will execute success, and print ``` {id=[], test1=6} ``` The value type of `id` is `List`, the value type of `test1` is `String`. But If we loop the map, it will throw a exception, because the value in this map has different type ```java String sqlResult = "{\"id\":[],\"test1\":\"6\"}"; Map<String, List> param = toMap(sqlResult, String.class, List.class); param.forEach((key, value) -> System.out.println(value)); ``` ``` [] Exception in thread "main" java.lang.ClassCastException: java.lang.String cannot be cast to java.util.List at java.util.LinkedHashMap.forEach(LinkedHashMap.java:684) at org.apache.dolphinscheduler.common.utils.JSONUtils.main(JSONUtils.java:256) ``` I don't find out the deep reason, but I think we should remove this method. **Which version of Dolphin Scheduler:** -[dev]
https://github.com/apache/dolphinscheduler/issues/6072
https://github.com/apache/dolphinscheduler/pull/6283
c855a5926ceb9cfb6efb0c901c8d92fe3774e999
46257834792d3316c9f5ef885f38e069e4eb6452
2021-08-31T10:30:15Z
java
2021-09-23T15:06:53Z
dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/utils/JSONUtilsTest.java
@Test public void parseObject() { String str = "{\"color\":\"yellow\",\"type\":\"renault\"}"; ObjectNode node = JSONUtils.parseObject(str); Assert.assertEquals("yellow", node.path("color").asText()); node.put("price", 100); Assert.assertEquals(100, node.path("price").asInt()); node.put("color", "red"); Assert.assertEquals("red", node.path("color").asText()); } @Test public void parseArray() { String str = "[{\"color\":\"yellow\",\"type\":\"renault\"}]"; ArrayNode node = JSONUtils.parseArray(str); Assert.assertEquals("yellow", node.path(0).path("color").asText()); } @Test public void jsonDataDeserializerTest() { String a = "{\"conditionResult\":\"{\\\"successNode\\\":[\\\"\\\"],\\\"failedNode\\\":[\\\"\\\"]}\"," + "\"conditionsTask\":false,\"depList\":[],\"dependence\":\"{}\",\"forbidden\":false," + "\"id\":\"tasks-86823\",\"maxRetryTimes\":1,\"name\":\"shell test\"," + "\"params\":\"{\\\"resourceList\\\":[],\\\"localParams\\\":[],\\\"rawScript\\\":\\\"echo " + "'yyc'\\\"}\",\"preTasks\":\"[]\",\"retryInterval\":1,\"runFlag\":\"NORMAL\"," + "\"taskInstancePriority\":\"HIGHEST\",\"taskTimeoutParameter\":{\"enable\":false,\"interval\":0}," + "\"timeout\":\"{}\",\"type\":\"SHELL\",\"workerGroup\":\"default\"}"; TaskNode taskNode = JSONUtils.parseObject(a, TaskNode.class); Assert.assertTrue(true); } }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,072
[Bug][common] Generics type is invalid in JsonUtils.toMap
**Describe the bug** This method is hope to deserialize a JSON to Map. https://github.com/apache/dolphinscheduler/blob/e866d1be86464d812551e8c38ba60767a204c82e/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/JSONUtils.java#L249-L251 But the generics type in the Map is not what we expected. We can write a simple test case: ```java String sqlResult = "{\"id\":[],\"test1\":\"6\"}"; Map<String, List> param = toMap(sqlResult, String.class, List.class); System.out.println(param); ``` It will execute success, and print ``` {id=[], test1=6} ``` The value type of `id` is `List`, the value type of `test1` is `String`. But If we loop the map, it will throw a exception, because the value in this map has different type ```java String sqlResult = "{\"id\":[],\"test1\":\"6\"}"; Map<String, List> param = toMap(sqlResult, String.class, List.class); param.forEach((key, value) -> System.out.println(value)); ``` ``` [] Exception in thread "main" java.lang.ClassCastException: java.lang.String cannot be cast to java.util.List at java.util.LinkedHashMap.forEach(LinkedHashMap.java:684) at org.apache.dolphinscheduler.common.utils.JSONUtils.main(JSONUtils.java:256) ``` I don't find out the deep reason, but I think we should remove this method. **Which version of Dolphin Scheduler:** -[dev]
https://github.com/apache/dolphinscheduler/issues/6072
https://github.com/apache/dolphinscheduler/pull/6283
c855a5926ceb9cfb6efb0c901c8d92fe3774e999
46257834792d3316c9f5ef885f38e069e4eb6452
2021-08-31T10:30:15Z
java
2021-09-23T15:06:53Z
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/TaskInstance.java
/* * 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 *
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,072
[Bug][common] Generics type is invalid in JsonUtils.toMap
**Describe the bug** This method is hope to deserialize a JSON to Map. https://github.com/apache/dolphinscheduler/blob/e866d1be86464d812551e8c38ba60767a204c82e/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/JSONUtils.java#L249-L251 But the generics type in the Map is not what we expected. We can write a simple test case: ```java String sqlResult = "{\"id\":[],\"test1\":\"6\"}"; Map<String, List> param = toMap(sqlResult, String.class, List.class); System.out.println(param); ``` It will execute success, and print ``` {id=[], test1=6} ``` The value type of `id` is `List`, the value type of `test1` is `String`. But If we loop the map, it will throw a exception, because the value in this map has different type ```java String sqlResult = "{\"id\":[],\"test1\":\"6\"}"; Map<String, List> param = toMap(sqlResult, String.class, List.class); param.forEach((key, value) -> System.out.println(value)); ``` ``` [] Exception in thread "main" java.lang.ClassCastException: java.lang.String cannot be cast to java.util.List at java.util.LinkedHashMap.forEach(LinkedHashMap.java:684) at org.apache.dolphinscheduler.common.utils.JSONUtils.main(JSONUtils.java:256) ``` I don't find out the deep reason, but I think we should remove this method. **Which version of Dolphin Scheduler:** -[dev]
https://github.com/apache/dolphinscheduler/issues/6072
https://github.com/apache/dolphinscheduler/pull/6283
c855a5926ceb9cfb6efb0c901c8d92fe3774e999
46257834792d3316c9f5ef885f38e069e4eb6452
2021-08-31T10:30:15Z
java
2021-09-23T15:06:53Z
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/TaskInstance.java
* 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.dolphinscheduler.dao.entity; import org.apache.dolphinscheduler.common.Constants; import org.apache.dolphinscheduler.common.enums.ExecutionStatus; import org.apache.dolphinscheduler.common.enums.Flag; import org.apache.dolphinscheduler.common.enums.Priority; import org.apache.dolphinscheduler.common.enums.TaskType; import org.apache.dolphinscheduler.common.task.dependent.DependentParameters; import org.apache.dolphinscheduler.common.task.switchtask.SwitchParameters; import org.apache.dolphinscheduler.common.utils.JSONUtils; import java.io.Serializable; import java.util.Date; import java.util.Map; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import com.fasterxml.jackson.annotation.JsonFormat; /** * task instance */ @TableName("t_ds_task_instance") public class TaskInstance implements Serializable {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,072
[Bug][common] Generics type is invalid in JsonUtils.toMap
**Describe the bug** This method is hope to deserialize a JSON to Map. https://github.com/apache/dolphinscheduler/blob/e866d1be86464d812551e8c38ba60767a204c82e/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/JSONUtils.java#L249-L251 But the generics type in the Map is not what we expected. We can write a simple test case: ```java String sqlResult = "{\"id\":[],\"test1\":\"6\"}"; Map<String, List> param = toMap(sqlResult, String.class, List.class); System.out.println(param); ``` It will execute success, and print ``` {id=[], test1=6} ``` The value type of `id` is `List`, the value type of `test1` is `String`. But If we loop the map, it will throw a exception, because the value in this map has different type ```java String sqlResult = "{\"id\":[],\"test1\":\"6\"}"; Map<String, List> param = toMap(sqlResult, String.class, List.class); param.forEach((key, value) -> System.out.println(value)); ``` ``` [] Exception in thread "main" java.lang.ClassCastException: java.lang.String cannot be cast to java.util.List at java.util.LinkedHashMap.forEach(LinkedHashMap.java:684) at org.apache.dolphinscheduler.common.utils.JSONUtils.main(JSONUtils.java:256) ``` I don't find out the deep reason, but I think we should remove this method. **Which version of Dolphin Scheduler:** -[dev]
https://github.com/apache/dolphinscheduler/issues/6072
https://github.com/apache/dolphinscheduler/pull/6283
c855a5926ceb9cfb6efb0c901c8d92fe3774e999
46257834792d3316c9f5ef885f38e069e4eb6452
2021-08-31T10:30:15Z
java
2021-09-23T15:06:53Z
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/TaskInstance.java
/** * id */ @TableId(value = "id", type = IdType.AUTO) private int id; /** * task name */ private String name; /** * task type */ private String taskType; /** * process instance id */ private int processInstanceId; /** * task code */ private long taskCode; /** * task definition version */ private int taskDefinitionVersion; /** * process instance name */ @TableField(exist = false) private String processInstanceName;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,072
[Bug][common] Generics type is invalid in JsonUtils.toMap
**Describe the bug** This method is hope to deserialize a JSON to Map. https://github.com/apache/dolphinscheduler/blob/e866d1be86464d812551e8c38ba60767a204c82e/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/JSONUtils.java#L249-L251 But the generics type in the Map is not what we expected. We can write a simple test case: ```java String sqlResult = "{\"id\":[],\"test1\":\"6\"}"; Map<String, List> param = toMap(sqlResult, String.class, List.class); System.out.println(param); ``` It will execute success, and print ``` {id=[], test1=6} ``` The value type of `id` is `List`, the value type of `test1` is `String`. But If we loop the map, it will throw a exception, because the value in this map has different type ```java String sqlResult = "{\"id\":[],\"test1\":\"6\"}"; Map<String, List> param = toMap(sqlResult, String.class, List.class); param.forEach((key, value) -> System.out.println(value)); ``` ``` [] Exception in thread "main" java.lang.ClassCastException: java.lang.String cannot be cast to java.util.List at java.util.LinkedHashMap.forEach(LinkedHashMap.java:684) at org.apache.dolphinscheduler.common.utils.JSONUtils.main(JSONUtils.java:256) ``` I don't find out the deep reason, but I think we should remove this method. **Which version of Dolphin Scheduler:** -[dev]
https://github.com/apache/dolphinscheduler/issues/6072
https://github.com/apache/dolphinscheduler/pull/6283
c855a5926ceb9cfb6efb0c901c8d92fe3774e999
46257834792d3316c9f5ef885f38e069e4eb6452
2021-08-31T10:30:15Z
java
2021-09-23T15:06:53Z
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/TaskInstance.java
/** * state */ private ExecutionStatus state; /** * task first submit time. */ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") private Date firstSubmitTime; /** * task submit time */ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") private Date submitTime; /** * task start time */ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") private Date startTime; /** * task end time */ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") private Date endTime; /** * task host */ private String host; /** * task shell execute path and the resource down from hdfs
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,072
[Bug][common] Generics type is invalid in JsonUtils.toMap
**Describe the bug** This method is hope to deserialize a JSON to Map. https://github.com/apache/dolphinscheduler/blob/e866d1be86464d812551e8c38ba60767a204c82e/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/JSONUtils.java#L249-L251 But the generics type in the Map is not what we expected. We can write a simple test case: ```java String sqlResult = "{\"id\":[],\"test1\":\"6\"}"; Map<String, List> param = toMap(sqlResult, String.class, List.class); System.out.println(param); ``` It will execute success, and print ``` {id=[], test1=6} ``` The value type of `id` is `List`, the value type of `test1` is `String`. But If we loop the map, it will throw a exception, because the value in this map has different type ```java String sqlResult = "{\"id\":[],\"test1\":\"6\"}"; Map<String, List> param = toMap(sqlResult, String.class, List.class); param.forEach((key, value) -> System.out.println(value)); ``` ``` [] Exception in thread "main" java.lang.ClassCastException: java.lang.String cannot be cast to java.util.List at java.util.LinkedHashMap.forEach(LinkedHashMap.java:684) at org.apache.dolphinscheduler.common.utils.JSONUtils.main(JSONUtils.java:256) ``` I don't find out the deep reason, but I think we should remove this method. **Which version of Dolphin Scheduler:** -[dev]
https://github.com/apache/dolphinscheduler/issues/6072
https://github.com/apache/dolphinscheduler/pull/6283
c855a5926ceb9cfb6efb0c901c8d92fe3774e999
46257834792d3316c9f5ef885f38e069e4eb6452
2021-08-31T10:30:15Z
java
2021-09-23T15:06:53Z
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/TaskInstance.java
* default path: $base_run_dir/processInstanceId/taskInstanceId/retryTimes */ private String executePath; /** * task log path * default path: $base_run_dir/processInstanceId/taskInstanceId/retryTimes */ private String logPath; /** * retry times */ private int retryTimes; /** * alert flag */ private Flag alertFlag; /** * process instance */ @TableField(exist = false) private ProcessInstance processInstance; /** * process definition */ @TableField(exist = false) private ProcessDefinition processDefine; /** * task definition */ @TableField(exist = false)
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,072
[Bug][common] Generics type is invalid in JsonUtils.toMap
**Describe the bug** This method is hope to deserialize a JSON to Map. https://github.com/apache/dolphinscheduler/blob/e866d1be86464d812551e8c38ba60767a204c82e/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/JSONUtils.java#L249-L251 But the generics type in the Map is not what we expected. We can write a simple test case: ```java String sqlResult = "{\"id\":[],\"test1\":\"6\"}"; Map<String, List> param = toMap(sqlResult, String.class, List.class); System.out.println(param); ``` It will execute success, and print ``` {id=[], test1=6} ``` The value type of `id` is `List`, the value type of `test1` is `String`. But If we loop the map, it will throw a exception, because the value in this map has different type ```java String sqlResult = "{\"id\":[],\"test1\":\"6\"}"; Map<String, List> param = toMap(sqlResult, String.class, List.class); param.forEach((key, value) -> System.out.println(value)); ``` ``` [] Exception in thread "main" java.lang.ClassCastException: java.lang.String cannot be cast to java.util.List at java.util.LinkedHashMap.forEach(LinkedHashMap.java:684) at org.apache.dolphinscheduler.common.utils.JSONUtils.main(JSONUtils.java:256) ``` I don't find out the deep reason, but I think we should remove this method. **Which version of Dolphin Scheduler:** -[dev]
https://github.com/apache/dolphinscheduler/issues/6072
https://github.com/apache/dolphinscheduler/pull/6283
c855a5926ceb9cfb6efb0c901c8d92fe3774e999
46257834792d3316c9f5ef885f38e069e4eb6452
2021-08-31T10:30:15Z
java
2021-09-23T15:06:53Z
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/TaskInstance.java
private TaskDefinition taskDefine; /** * process id */ private int pid; /** * appLink */ private String appLink; /** * flag */ private Flag flag; /** * dependency */ @TableField(exist = false) private DependentParameters dependency; /** * switch dependency */ @TableField(exist = false) private SwitchParameters switchDependency; /** * duration */ @TableField(exist = false) private String duration; /** * max retry times
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,072
[Bug][common] Generics type is invalid in JsonUtils.toMap
**Describe the bug** This method is hope to deserialize a JSON to Map. https://github.com/apache/dolphinscheduler/blob/e866d1be86464d812551e8c38ba60767a204c82e/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/JSONUtils.java#L249-L251 But the generics type in the Map is not what we expected. We can write a simple test case: ```java String sqlResult = "{\"id\":[],\"test1\":\"6\"}"; Map<String, List> param = toMap(sqlResult, String.class, List.class); System.out.println(param); ``` It will execute success, and print ``` {id=[], test1=6} ``` The value type of `id` is `List`, the value type of `test1` is `String`. But If we loop the map, it will throw a exception, because the value in this map has different type ```java String sqlResult = "{\"id\":[],\"test1\":\"6\"}"; Map<String, List> param = toMap(sqlResult, String.class, List.class); param.forEach((key, value) -> System.out.println(value)); ``` ``` [] Exception in thread "main" java.lang.ClassCastException: java.lang.String cannot be cast to java.util.List at java.util.LinkedHashMap.forEach(LinkedHashMap.java:684) at org.apache.dolphinscheduler.common.utils.JSONUtils.main(JSONUtils.java:256) ``` I don't find out the deep reason, but I think we should remove this method. **Which version of Dolphin Scheduler:** -[dev]
https://github.com/apache/dolphinscheduler/issues/6072
https://github.com/apache/dolphinscheduler/pull/6283
c855a5926ceb9cfb6efb0c901c8d92fe3774e999
46257834792d3316c9f5ef885f38e069e4eb6452
2021-08-31T10:30:15Z
java
2021-09-23T15:06:53Z
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/TaskInstance.java
*/ private int maxRetryTimes; /** * task retry interval, unit: minute */ private int retryInterval; /** * task intance priority */ private Priority taskInstancePriority; /** * process intance priority */ @TableField(exist = false) private Priority processInstancePriority; /** * dependent state */ @TableField(exist = false) private String dependentResult; /** * workerGroup */ private String workerGroup; /** * environment code */ private Long environmentCode; /** * environment config
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,072
[Bug][common] Generics type is invalid in JsonUtils.toMap
**Describe the bug** This method is hope to deserialize a JSON to Map. https://github.com/apache/dolphinscheduler/blob/e866d1be86464d812551e8c38ba60767a204c82e/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/JSONUtils.java#L249-L251 But the generics type in the Map is not what we expected. We can write a simple test case: ```java String sqlResult = "{\"id\":[],\"test1\":\"6\"}"; Map<String, List> param = toMap(sqlResult, String.class, List.class); System.out.println(param); ``` It will execute success, and print ``` {id=[], test1=6} ``` The value type of `id` is `List`, the value type of `test1` is `String`. But If we loop the map, it will throw a exception, because the value in this map has different type ```java String sqlResult = "{\"id\":[],\"test1\":\"6\"}"; Map<String, List> param = toMap(sqlResult, String.class, List.class); param.forEach((key, value) -> System.out.println(value)); ``` ``` [] Exception in thread "main" java.lang.ClassCastException: java.lang.String cannot be cast to java.util.List at java.util.LinkedHashMap.forEach(LinkedHashMap.java:684) at org.apache.dolphinscheduler.common.utils.JSONUtils.main(JSONUtils.java:256) ``` I don't find out the deep reason, but I think we should remove this method. **Which version of Dolphin Scheduler:** -[dev]
https://github.com/apache/dolphinscheduler/issues/6072
https://github.com/apache/dolphinscheduler/pull/6283
c855a5926ceb9cfb6efb0c901c8d92fe3774e999
46257834792d3316c9f5ef885f38e069e4eb6452
2021-08-31T10:30:15Z
java
2021-09-23T15:06:53Z
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/TaskInstance.java
*/ private String environmentConfig; /** * executor id */ private int executorId; /** * varPool string */ private String varPool; /** * executor name */ @TableField(exist = false) private String executorName; @TableField(exist = false) private Map<String, String> resources; /** * delay execution time. */ private int delayTime; /** * task params */ private String taskParams; public void init(String host, Date startTime, String executePath) { this.host = host; this.startTime = startTime; this.executePath = executePath; }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,072
[Bug][common] Generics type is invalid in JsonUtils.toMap
**Describe the bug** This method is hope to deserialize a JSON to Map. https://github.com/apache/dolphinscheduler/blob/e866d1be86464d812551e8c38ba60767a204c82e/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/JSONUtils.java#L249-L251 But the generics type in the Map is not what we expected. We can write a simple test case: ```java String sqlResult = "{\"id\":[],\"test1\":\"6\"}"; Map<String, List> param = toMap(sqlResult, String.class, List.class); System.out.println(param); ``` It will execute success, and print ``` {id=[], test1=6} ``` The value type of `id` is `List`, the value type of `test1` is `String`. But If we loop the map, it will throw a exception, because the value in this map has different type ```java String sqlResult = "{\"id\":[],\"test1\":\"6\"}"; Map<String, List> param = toMap(sqlResult, String.class, List.class); param.forEach((key, value) -> System.out.println(value)); ``` ``` [] Exception in thread "main" java.lang.ClassCastException: java.lang.String cannot be cast to java.util.List at java.util.LinkedHashMap.forEach(LinkedHashMap.java:684) at org.apache.dolphinscheduler.common.utils.JSONUtils.main(JSONUtils.java:256) ``` I don't find out the deep reason, but I think we should remove this method. **Which version of Dolphin Scheduler:** -[dev]
https://github.com/apache/dolphinscheduler/issues/6072
https://github.com/apache/dolphinscheduler/pull/6283
c855a5926ceb9cfb6efb0c901c8d92fe3774e999
46257834792d3316c9f5ef885f38e069e4eb6452
2021-08-31T10:30:15Z
java
2021-09-23T15:06:53Z
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/TaskInstance.java
public String getVarPool() { return varPool; } public void setVarPool(String varPool) { this.varPool = varPool; } public ProcessInstance getProcessInstance() { return processInstance; } public void setProcessInstance(ProcessInstance processInstance) { this.processInstance = processInstance; } public ProcessDefinition getProcessDefine() { return processDefine; } public void setProcessDefine(ProcessDefinition processDefine) { this.processDefine = processDefine; } public TaskDefinition getTaskDefine() { return taskDefine; } public void setTaskDefine(TaskDefinition taskDefine) { this.taskDefine = taskDefine; } public int getId() { return id; } public void setId(int id) { this.id = id; }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,072
[Bug][common] Generics type is invalid in JsonUtils.toMap
**Describe the bug** This method is hope to deserialize a JSON to Map. https://github.com/apache/dolphinscheduler/blob/e866d1be86464d812551e8c38ba60767a204c82e/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/JSONUtils.java#L249-L251 But the generics type in the Map is not what we expected. We can write a simple test case: ```java String sqlResult = "{\"id\":[],\"test1\":\"6\"}"; Map<String, List> param = toMap(sqlResult, String.class, List.class); System.out.println(param); ``` It will execute success, and print ``` {id=[], test1=6} ``` The value type of `id` is `List`, the value type of `test1` is `String`. But If we loop the map, it will throw a exception, because the value in this map has different type ```java String sqlResult = "{\"id\":[],\"test1\":\"6\"}"; Map<String, List> param = toMap(sqlResult, String.class, List.class); param.forEach((key, value) -> System.out.println(value)); ``` ``` [] Exception in thread "main" java.lang.ClassCastException: java.lang.String cannot be cast to java.util.List at java.util.LinkedHashMap.forEach(LinkedHashMap.java:684) at org.apache.dolphinscheduler.common.utils.JSONUtils.main(JSONUtils.java:256) ``` I don't find out the deep reason, but I think we should remove this method. **Which version of Dolphin Scheduler:** -[dev]
https://github.com/apache/dolphinscheduler/issues/6072
https://github.com/apache/dolphinscheduler/pull/6283
c855a5926ceb9cfb6efb0c901c8d92fe3774e999
46257834792d3316c9f5ef885f38e069e4eb6452
2021-08-31T10:30:15Z
java
2021-09-23T15:06:53Z
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/TaskInstance.java
public String getName() { return name; } public void setName(String name) { this.name = name; } public String getTaskType() { return taskType; } public void setTaskType(String taskType) { this.taskType = taskType; } public int getProcessInstanceId() { return processInstanceId; } public void setProcessInstanceId(int processInstanceId) { this.processInstanceId = processInstanceId; } public ExecutionStatus getState() { return state; } public void setState(ExecutionStatus state) { this.state = state; } public Date getFirstSubmitTime() { return firstSubmitTime; } public void setFirstSubmitTime(Date firstSubmitTime) { this.firstSubmitTime = firstSubmitTime; }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,072
[Bug][common] Generics type is invalid in JsonUtils.toMap
**Describe the bug** This method is hope to deserialize a JSON to Map. https://github.com/apache/dolphinscheduler/blob/e866d1be86464d812551e8c38ba60767a204c82e/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/JSONUtils.java#L249-L251 But the generics type in the Map is not what we expected. We can write a simple test case: ```java String sqlResult = "{\"id\":[],\"test1\":\"6\"}"; Map<String, List> param = toMap(sqlResult, String.class, List.class); System.out.println(param); ``` It will execute success, and print ``` {id=[], test1=6} ``` The value type of `id` is `List`, the value type of `test1` is `String`. But If we loop the map, it will throw a exception, because the value in this map has different type ```java String sqlResult = "{\"id\":[],\"test1\":\"6\"}"; Map<String, List> param = toMap(sqlResult, String.class, List.class); param.forEach((key, value) -> System.out.println(value)); ``` ``` [] Exception in thread "main" java.lang.ClassCastException: java.lang.String cannot be cast to java.util.List at java.util.LinkedHashMap.forEach(LinkedHashMap.java:684) at org.apache.dolphinscheduler.common.utils.JSONUtils.main(JSONUtils.java:256) ``` I don't find out the deep reason, but I think we should remove this method. **Which version of Dolphin Scheduler:** -[dev]
https://github.com/apache/dolphinscheduler/issues/6072
https://github.com/apache/dolphinscheduler/pull/6283
c855a5926ceb9cfb6efb0c901c8d92fe3774e999
46257834792d3316c9f5ef885f38e069e4eb6452
2021-08-31T10:30:15Z
java
2021-09-23T15:06:53Z
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/TaskInstance.java
public Date getSubmitTime() { return submitTime; } public void setSubmitTime(Date submitTime) { this.submitTime = submitTime; } public Date getStartTime() { return startTime; } public void setStartTime(Date startTime) { this.startTime = startTime; } public Date getEndTime() { return endTime; } public void setEndTime(Date endTime) { this.endTime = endTime; } public String getHost() { return host; } public void setHost(String host) { this.host = host; } public String getExecutePath() { return executePath; } public void setExecutePath(String executePath) { this.executePath = executePath; }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,072
[Bug][common] Generics type is invalid in JsonUtils.toMap
**Describe the bug** This method is hope to deserialize a JSON to Map. https://github.com/apache/dolphinscheduler/blob/e866d1be86464d812551e8c38ba60767a204c82e/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/JSONUtils.java#L249-L251 But the generics type in the Map is not what we expected. We can write a simple test case: ```java String sqlResult = "{\"id\":[],\"test1\":\"6\"}"; Map<String, List> param = toMap(sqlResult, String.class, List.class); System.out.println(param); ``` It will execute success, and print ``` {id=[], test1=6} ``` The value type of `id` is `List`, the value type of `test1` is `String`. But If we loop the map, it will throw a exception, because the value in this map has different type ```java String sqlResult = "{\"id\":[],\"test1\":\"6\"}"; Map<String, List> param = toMap(sqlResult, String.class, List.class); param.forEach((key, value) -> System.out.println(value)); ``` ``` [] Exception in thread "main" java.lang.ClassCastException: java.lang.String cannot be cast to java.util.List at java.util.LinkedHashMap.forEach(LinkedHashMap.java:684) at org.apache.dolphinscheduler.common.utils.JSONUtils.main(JSONUtils.java:256) ``` I don't find out the deep reason, but I think we should remove this method. **Which version of Dolphin Scheduler:** -[dev]
https://github.com/apache/dolphinscheduler/issues/6072
https://github.com/apache/dolphinscheduler/pull/6283
c855a5926ceb9cfb6efb0c901c8d92fe3774e999
46257834792d3316c9f5ef885f38e069e4eb6452
2021-08-31T10:30:15Z
java
2021-09-23T15:06:53Z
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/TaskInstance.java
public String getLogPath() { return logPath; } public void setLogPath(String logPath) { this.logPath = logPath; } public Flag getAlertFlag() { return alertFlag; } public void setAlertFlag(Flag alertFlag) { this.alertFlag = alertFlag; } public int getRetryTimes() { return retryTimes; } public void setRetryTimes(int retryTimes) { this.retryTimes = retryTimes; } public Boolean isTaskSuccess() { return this.state == ExecutionStatus.SUCCESS; } public int getPid() { return pid; } public void setPid(int pid) { this.pid = pid; } public String getAppLink() { return appLink; }