Browse Source

Fix switch task will throw exception when there is not parameters (#15594)

dev_wenjun_refactorMaster
Wenjun Ruan 9 months ago committed by GitHub
parent
commit
8a35e8b2f8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 2
      dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/utils/SwitchTaskUtils.java
  2. 5
      dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/utils/SwitchTaskUtilsTest.java

2
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/utils/SwitchTaskUtils.java

@ -66,7 +66,7 @@ public class SwitchTaskUtils {
Map<String, Property> varParams) { Map<String, Property> varParams) {
String content = condition.replaceAll("'", "\""); String content = condition.replaceAll("'", "\"");
if (MapUtils.isEmpty(globalParams) && MapUtils.isEmpty(varParams)) { if (MapUtils.isEmpty(globalParams) && MapUtils.isEmpty(varParams)) {
throw new IllegalArgumentException("globalParams and varParams are both empty, please check it."); return content;
} }
Map<String, Property> params = Maps.newHashMap(); Map<String, Property> params = Maps.newHashMap();
if (MapUtils.isNotEmpty(globalParams)) { if (MapUtils.isNotEmpty(globalParams)) {

5
dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/utils/SwitchTaskUtilsTest.java

@ -34,9 +34,8 @@ public class SwitchTaskUtilsTest {
String content = "${test}==1"; String content = "${test}==1";
Map<String, Property> globalParams = new HashMap<>(); Map<String, Property> globalParams = new HashMap<>();
Map<String, Property> varParams = new HashMap<>(); Map<String, Property> varParams = new HashMap<>();
Assertions.assertThrowsExactly(IllegalArgumentException.class, () -> { Assertions.assertDoesNotThrow(
SwitchTaskUtils.generateContentWithTaskParams(content, globalParams, varParams); () -> SwitchTaskUtils.generateContentWithTaskParams(content, globalParams, varParams));
});
globalParams.put("test", new Property("test", Direct.IN, DataType.INTEGER, "1")); globalParams.put("test", new Property("test", Direct.IN, DataType.INTEGER, "1"));
String result = SwitchTaskUtils.generateContentWithTaskParams(content, globalParams, varParams); String result = SwitchTaskUtils.generateContentWithTaskParams(content, globalParams, varParams);

Loading…
Cancel
Save