Browse Source

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

3.2.2-prepare
Wenjun Ruan 10 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) {
String content = condition.replaceAll("'", "\"");
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();
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";
Map<String, Property> globalParams = new HashMap<>();
Map<String, Property> varParams = new HashMap<>();
Assertions.assertThrowsExactly(IllegalArgumentException.class, () -> {
SwitchTaskUtils.generateContentWithTaskParams(content, globalParams, varParams);
});
Assertions.assertDoesNotThrow(
() -> SwitchTaskUtils.generateContentWithTaskParams(content, globalParams, varParams));
globalParams.put("test", new Property("test", Direct.IN, DataType.INTEGER, "1"));
String result = SwitchTaskUtils.generateContentWithTaskParams(content, globalParams, varParams);

Loading…
Cancel
Save