mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-10 19:51:00 +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.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.Properties;
|
||||
|
||||
@Slf4j
|
||||
@@ -149,15 +150,17 @@ public abstract class BaseDbAdaptor implements DbAdaptor {
|
||||
// 设置通用属性
|
||||
properties.setProperty("user", connectionInfo.getUserName());
|
||||
|
||||
|
||||
String password = Optional.ofNullable(connectionInfo.getPassword()).orElse("");
|
||||
// 针对 Presto 和 Trino ssl=false 的情况,不需要设置密码
|
||||
if (url.startsWith("jdbc:presto") || url.startsWith("jdbc:trino")) {
|
||||
// 检查是否需要处理 SSL
|
||||
if (!url.contains("ssl=false")) {
|
||||
properties.setProperty("password", connectionInfo.getPassword());
|
||||
properties.setProperty("password", password);
|
||||
}
|
||||
} else {
|
||||
// 针对其他数据库类型
|
||||
properties.setProperty("password", connectionInfo.getPassword());
|
||||
properties.setProperty("password", password);
|
||||
}
|
||||
|
||||
return properties;
|
||||
|
||||
Reference in New Issue
Block a user