Copilot commented on code in PR #18291:
URL: https://github.com/apache/iotdb/pull/18291#discussion_r3637275898


##########
iotdb-client/cli/src/main/i18n/en/org/apache/iotdb/cli/i18n/CliMessages.java:
##########
@@ -24,6 +24,9 @@ public final class CliMessages {
   // CliContext
   public static final String EXITING_WITH_CODE = "Exiting with code %d";
 
+  // Cli
+  public static final String SUCCESSFULLY_LOGIN_AT = "Successfully login at 
%s";
+

Review Comment:
   The new login message text is grammatically incorrect ("Successfully 
login"). Consider using past tense ("Successfully logged in") for clearer 
English output.



##########
iotdb-client/cli/src/main/java/org/apache/iotdb/cli/Cli.java:
##########
@@ -241,6 +242,14 @@ private static void receiveCommands(CliContext ctx) throws 
TException {
     }
   }
 
+  private static String formatEndpoint(String host, String port) {
+    return UrlUtils.formatTEndPointIpv4AndIpv6Url(host, 
Integer.parseInt(port));
+  }
+
+  private static String buildJdbcUrl(String host, String port) {
+    return Config.IOTDB_URL_PREFIX + formatEndpoint(host, port) + "/";
+  }

Review Comment:
   formatEndpoint/buildJdbcUrl now parse the port with Integer.parseInt(port). 
If the user passes a non-integer port, this will throw a NumberFormatException 
and the CLI will exit with a generic "For input string" message. Catch this and 
throw a clearer error to improve diagnosability.



##########
iotdb-client/cli/src/main/java/org/apache/iotdb/tool/data/ImportDataTable.java:
##########
@@ -79,7 +80,9 @@ public class ImportDataTable extends AbstractImportData {
   public void init() throws InterruptedException {
     TableSessionPoolBuilder tableSessionPoolBuilder =
         new TableSessionPoolBuilder()
-            .nodeUrls(Collections.singletonList(host + ":" + port))
+            .nodeUrls(
+                Collections.singletonList(
+                    UrlUtils.formatTEndPointIpv4AndIpv6Url(host, 
Integer.parseInt(port))))

Review Comment:
   This code now parses the port inline via Integer.parseInt(port). If the port 
argument is not a valid integer, the tool will fail with a generic 
NumberFormatException message ("For input string"). Parsing once with a clearer 
exception makes failures easier to diagnose.



##########
iotdb-client/cli/src/main/java/org/apache/iotdb/tool/data/ExportDataTable.java:
##########
@@ -65,7 +66,9 @@ public class ExportDataTable extends AbstractExportData {
   public void init() throws IoTDBConnectionException, 
StatementExecutionException {
     TableSessionBuilder tableSessionBuilder =
         new TableSessionBuilder()
-            .nodeUrls(Collections.singletonList(host + ":" + port))
+            .nodeUrls(
+                Collections.singletonList(
+                    UrlUtils.formatTEndPointIpv4AndIpv6Url(host, 
Integer.parseInt(port))))

Review Comment:
   This code now parses the port inline via Integer.parseInt(port). If the port 
argument is not a valid integer, the tool will fail with a generic 
NumberFormatException message ("For input string"). Parsing once with a clearer 
exception makes failures easier to diagnose.



##########
iotdb-client/cli/src/main/java/org/apache/iotdb/tool/schema/ImportSchemaTable.java:
##########
@@ -51,7 +52,9 @@ public class ImportSchemaTable extends AbstractImportSchema {
   public void init() throws InterruptedException {
     TableSessionPoolBuilder tableSessionPoolBuilder =
         new TableSessionPoolBuilder()
-            .nodeUrls(Collections.singletonList(host + ":" + port))
+            .nodeUrls(
+                Collections.singletonList(
+                    UrlUtils.formatTEndPointIpv4AndIpv6Url(host, 
Integer.parseInt(port))))

Review Comment:
   This code now parses the port inline via Integer.parseInt(port). If the port 
argument is not a valid integer, the tool will fail with a generic 
NumberFormatException message ("For input string"). Parsing once with a clearer 
exception makes failures easier to diagnose.



##########
iotdb-client/cli/src/main/java/org/apache/iotdb/tool/schema/ExportSchemaTable.java:
##########
@@ -55,7 +56,9 @@ public class ExportSchemaTable extends AbstractExportSchema {
   public void init() throws InterruptedException {
     TableSessionPoolBuilder tableSessionPoolBuilder =
         new TableSessionPoolBuilder()
-            .nodeUrls(Collections.singletonList(host + ":" + port))
+            .nodeUrls(
+                Collections.singletonList(
+                    UrlUtils.formatTEndPointIpv4AndIpv6Url(host, 
Integer.parseInt(port))))

Review Comment:
   This code now parses the port inline via Integer.parseInt(port). If the port 
argument is not a valid integer, the tool will fail with a generic 
NumberFormatException message ("For input string"). Parsing once with a clearer 
exception makes failures easier to diagnose.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to