[fix-5737] [Bug][Datasource] datsource other param check error (#5835)

Co-authored-by: wanggang <wanggy01@servyou.com.cn>
This commit is contained in:
geosmart 2021-07-18 21:46:58 +08:00 committed by GitHub
parent 9ae2266cd4
commit 2df6ee1efb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 2 deletions

View File

@ -30,7 +30,7 @@ public abstract class AbstractDatasourceProcessor implements DatasourceProcessor
private static final Pattern DATABASE_PATTER = Pattern.compile("^[a-zA-Z0-9\\_\\-\\.]+$");
private static final Pattern PARAMS_PATTER = Pattern.compile("^[a-zA-Z0-9]+$");
private static final Pattern PARAMS_PATTER = Pattern.compile("^[a-zA-Z0-9\\-\\_\\/]+$");
@Override
public void checkDatasourceParam(BaseDataSourceParamDTO baseDataSourceParamDTO) {

View File

@ -17,6 +17,8 @@
package org.apache.dolphinscheduler.common.datasource;
import java.util.HashMap;
import java.util.Map;
import org.apache.dolphinscheduler.common.datasource.mysql.MysqlConnectionParam;
import org.apache.dolphinscheduler.common.datasource.mysql.MysqlDatasourceParamDTO;
import org.apache.dolphinscheduler.common.datasource.mysql.MysqlDatasourceProcessor;
@ -44,7 +46,11 @@ public class DatasourceUtilTest {
MysqlDatasourceParamDTO mysqlDatasourceParamDTO = new MysqlDatasourceParamDTO();
mysqlDatasourceParamDTO.setHost("localhost");
mysqlDatasourceParamDTO.setDatabase("default");
mysqlDatasourceParamDTO.setOther(null);
Map<String, String> other = new HashMap<>();
other.put("serverTimezone", "Asia/Shanghai");
other.put("queryTimeout", "-1");
other.put("characterEncoding", "utf8");
mysqlDatasourceParamDTO.setOther(other);
DatasourceUtil.checkDatasourceParam(mysqlDatasourceParamDTO);
Assert.assertTrue(true);
}