mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-13 21:17:08 +00:00
(fix)(headless) method getProperties maybe cause NullPointerException (#2202)
This commit is contained in:
@@ -10,6 +10,7 @@ import org.apache.commons.lang3.StringUtils;
|
|||||||
import java.sql.*;
|
import java.sql.*;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@@ -149,15 +150,17 @@ public abstract class BaseDbAdaptor implements DbAdaptor {
|
|||||||
// 设置通用属性
|
// 设置通用属性
|
||||||
properties.setProperty("user", connectionInfo.getUserName());
|
properties.setProperty("user", connectionInfo.getUserName());
|
||||||
|
|
||||||
|
|
||||||
|
String password = Optional.ofNullable(connectionInfo.getPassword()).orElse("");
|
||||||
// 针对 Presto 和 Trino ssl=false 的情况,不需要设置密码
|
// 针对 Presto 和 Trino ssl=false 的情况,不需要设置密码
|
||||||
if (url.startsWith("jdbc:presto") || url.startsWith("jdbc:trino")) {
|
if (url.startsWith("jdbc:presto") || url.startsWith("jdbc:trino")) {
|
||||||
// 检查是否需要处理 SSL
|
// 检查是否需要处理 SSL
|
||||||
if (!url.contains("ssl=false")) {
|
if (!url.contains("ssl=false")) {
|
||||||
properties.setProperty("password", connectionInfo.getPassword());
|
properties.setProperty("password", password);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// 针对其他数据库类型
|
// 针对其他数据库类型
|
||||||
properties.setProperty("password", connectionInfo.getPassword());
|
properties.setProperty("password", password);
|
||||||
}
|
}
|
||||||
|
|
||||||
return properties;
|
return properties;
|
||||||
|
|||||||
Reference in New Issue
Block a user