This is an automated email from the ASF dual-hosted git repository. jackietien pushed a commit to branch IOTDB-6312 in repository https://gitbox.apache.org/repos/asf/iotdb.git
commit 1de73d534139de54a258ba0dbbfef6dc1bc2cdc7 Author: JackieTien97 <[email protected]> AuthorDate: Mon Mar 18 14:51:35 2024 +0800 Throw correct error msg while using wrong password --- .../src/main/java/org/apache/iotdb/SessionPoolExample.java | 2 +- .../java/org/apache/iotdb/session/SessionConnection.java | 13 +++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/example/session/src/main/java/org/apache/iotdb/SessionPoolExample.java b/example/session/src/main/java/org/apache/iotdb/SessionPoolExample.java index 1857b71ff4e..f6da38d5ddb 100644 --- a/example/session/src/main/java/org/apache/iotdb/SessionPoolExample.java +++ b/example/session/src/main/java/org/apache/iotdb/SessionPoolExample.java @@ -62,7 +62,7 @@ public class SessionPoolExample { new SessionPool.Builder() .nodeUrls(nodeUrls) .user("root") - .password("root") + .password("root1") .maxSize(3) .build(); } diff --git a/iotdb-client/session/src/main/java/org/apache/iotdb/session/SessionConnection.java b/iotdb-client/session/src/main/java/org/apache/iotdb/session/SessionConnection.java index fb701a65277..7f29e5e9b3f 100644 --- a/iotdb-client/session/src/main/java/org/apache/iotdb/session/SessionConnection.java +++ b/iotdb-client/session/src/main/java/org/apache/iotdb/session/SessionConnection.java @@ -128,6 +128,8 @@ public class SessionConnection { this.retryIntervalInMs = Math.max(0, retryIntervalInMs); try { init(endPoint, session.useSSL, session.trustStore, session.trustStorePwd); + } catch (StatementExecutionException e) { + throw new IoTDBConnectionException(e.getMessage()); } catch (IoTDBConnectionException e) { throw new IoTDBConnectionException(logForReconnectionFailure()); } @@ -150,7 +152,7 @@ public class SessionConnection { } private void init(TEndPoint endPoint, boolean useSSL, String trustStore, String trustStorePwd) - throws IoTDBConnectionException { + throws IoTDBConnectionException, StatementExecutionException { DeepCopyRpcTransportFactory.setDefaultBufferCapacity(session.thriftDefaultBufferSize); DeepCopyRpcTransportFactory.setThriftMaxFrameSize(session.thriftMaxFrameSize); try { @@ -211,6 +213,9 @@ public class SessionConnection { sessionId = openResp.getSessionId(); statementId = client.requestStatementId(sessionId); + } catch (StatementExecutionException e) { + transport.close(); + throw e; } catch (Exception e) { transport.close(); throw new IoTDBConnectionException(e); @@ -228,6 +233,8 @@ public class SessionConnection { logger.error("Cluster has no nodes to connect"); throw new IoTDBConnectionException(logForReconnectionFailure()); } + } catch (StatementExecutionException e) { + throw new IoTDBConnectionException(e.getMessage()); } break; } @@ -1386,8 +1393,10 @@ public class SessionConnection { init(endPoint, session.useSSL, session.trustStore, session.trustStorePwd); connectedSuccess = true; } catch (IoTDBConnectionException e) { - logger.warn("The current node may have been down {},try next node", endPoint); + logger.warn("The current node may have been down {}, try next node", endPoint); continue; + } catch (StatementExecutionException e) { + logger.warn("login in failed, because {}", e.getMessage()); } break; }
