Browse Source

[Bug-13782] match ')' in setValue regular expression (#13787)

3.2.0-release
Aaron Wang 2 years ago committed by GitHub
parent
commit
b98566e070
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/TaskConstants.java
  2. 20
      dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/test/java/org/apache/dolphinscheduler/plugin/task/api/AbstractTaskTest.java

2
dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/TaskConstants.java

@ -33,7 +33,7 @@ public class TaskConstants {
public static final String FLINK_APPLICATION_REGEX = "JobID \\w+";
public static final String SETVALUE_REGEX = "[\\$#]\\{setValue\\(([^)]*)\\)}";
public static final String SETVALUE_REGEX = "[\\$#]\\{setValue\\((.*?)\\)}";
/**
* string false

20
dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/test/java/org/apache/dolphinscheduler/plugin/task/api/AbstractTaskTest.java

@ -38,4 +38,24 @@ public class AbstractTaskTest {
Assertions.assertEquals(jobId, str.substring(6));
}
@Test
public void testSetValue() {
Pattern SETVALUE_REGEX = Pattern.compile(TaskConstants.SETVALUE_REGEX);
String line1 = "${setValue(sql=\"INSERT INTO a VALUES (1, 2);\")}";
String line2 = "${setValue(a=2))}";
Matcher matcher1 = SETVALUE_REGEX.matcher(line1);
String str1 = null;
if (matcher1.find()) {
str1 = matcher1.group();
}
String str2 = null;
Matcher matcher2 = SETVALUE_REGEX.matcher(line2);
if (matcher2.find()) {
str2 = matcher2.group();
}
Assertions.assertNotNull(str1);
Assertions.assertNotNull(str2);
Assertions.assertEquals(str1.length(), line1.length());
Assertions.assertEquals(str2.length(), line2.length());
}
}

Loading…
Cancel
Save