Skip to content

Commit

Permalink
fix npe
Browse files Browse the repository at this point in the history
  • Loading branch information
pan3793 committed Jul 27, 2022
1 parent 4cb73df commit 3b5e6ce
Showing 1 changed file with 6 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ public static List<JdbcConnectionParams> getAllUrls(String zookeeperBasedHS2Url)
}

public KyuubiConnection(String uri, Properties info) throws SQLException {
setupTimeout();
try {
connParams = Utils.parseURL(uri, info);
} catch (ZooKeeperHiveClientException e) {
Expand All @@ -140,6 +139,7 @@ public KyuubiConnection(String uri, Properties info) throws SQLException {
host = Utils.getCanonicalHostName(connParams.getHost());
port = connParams.getPort();
sessConfMap = connParams.getSessionVars();
setupTimeout();

if (sessConfMap.containsKey(FETCH_SIZE)) {
fetchSize = Integer.parseInt(sessConfMap.get(FETCH_SIZE));
Expand Down Expand Up @@ -868,24 +868,22 @@ private String getSessionValue(String varName, String varDefault) {

private void setupTimeout() {
if (sessConfMap.containsKey(CONNECT_TIMEOUT)) {
long connectTimeoutMs = 0;
String loginTimeoutStr = getSessionValue(CONNECT_TIMEOUT, "0");
String loginTimeoutStr = sessConfMap.get(CONNECT_TIMEOUT);
try {
connectTimeoutMs = Long.parseLong(loginTimeoutStr);
long connectTimeoutMs = Long.parseLong(loginTimeoutStr);
connectTimeout = (int) Math.max(0, Math.min(connectTimeoutMs, Integer.MAX_VALUE));
} catch (NumberFormatException e) {
LOG.info("Failed to parse connectTimeout of value " + loginTimeoutStr);
}
connectTimeout = (int) Math.max(0, Math.min(connectTimeoutMs, Integer.MAX_VALUE));
}
if (sessConfMap.containsKey(SOCKET_TIMEOUT)) {
long socketTimeoutMs = 0;
String socketTimeoutStr = sessConfMap.get(SOCKET_TIMEOUT);
try {
socketTimeoutMs = Long.parseLong(socketTimeoutStr);
long socketTimeoutMs = Long.parseLong(socketTimeoutStr);
socketTimeout = (int) Math.max(0, Math.min(socketTimeoutMs, Integer.MAX_VALUE));
} catch (NumberFormatException e) {
LOG.info("Failed to parse socketTimeout of value " + socketTimeoutStr);
}
socketTimeout = (int) Math.max(0, Math.min(socketTimeoutMs, Integer.MAX_VALUE));
}
}

Expand Down

0 comments on commit 3b5e6ce

Please sign in to comment.