sunrisefromdark commented on code in PR #9012:
URL: https://github.com/apache/inlong/pull/9012#discussion_r1352305110
##########
inlong-manager/manager-common/src/main/java/org/apache/inlong/manager/common/util/ValidationUtils.java:
##########
@@ -43,4 +43,39 @@ public static void validate(Validator validator, Object
object, Class<?>... grou
}
}
+ /**
+ * Extracts the hostname and validates the port from a JDBC URL with the
specified prefix.
+ *
+ * @param fullUrl The full JDBC URL to extract the hostname and port from
+ * @param prefix The expected prefix of the JDBC URL
+ * @throws Exception If the URL format is invalid or the port is invalid
+ */
+ public static void extractHostAndValidatePortFromJdbcUrl(String fullUrl,
String prefix) throws Exception {
+ if (!fullUrl.startsWith(prefix)) {
+ throw new Exception("Invalid JDBC URL, it should start with " +
prefix);
+ }
+ // Extract the host and port part after the prefix
+ String hostPortPart = fullUrl.substring(prefix.length() + 3);
+ String[] hostPortParts = hostPortPart.split("/");
Review Comment:
done
##########
inlong-manager/manager-common/src/main/java/org/apache/inlong/manager/common/util/ValidationUtils.java:
##########
@@ -43,4 +43,39 @@ public static void validate(Validator validator, Object
object, Class<?>... grou
}
}
+ /**
+ * Extracts the hostname and validates the port from a JDBC URL with the
specified prefix.
+ *
+ * @param fullUrl The full JDBC URL to extract the hostname and port from
+ * @param prefix The expected prefix of the JDBC URL
+ * @throws Exception If the URL format is invalid or the port is invalid
+ */
+ public static void extractHostAndValidatePortFromJdbcUrl(String fullUrl,
String prefix) throws Exception {
+ if (!fullUrl.startsWith(prefix)) {
+ throw new Exception("Invalid JDBC URL, it should start with " +
prefix);
+ }
+ // Extract the host and port part after the prefix
+ String hostPortPart = fullUrl.substring(prefix.length() + 3);
+ String[] hostPortParts = hostPortPart.split("/");
+
+ if (hostPortParts.length < 1) {
+ throw new Exception("Invalid JDBC URL format");
+ }
+ String hostPort = hostPortParts[0];
+ String[] hostPortSplit = hostPort.split(":");
Review Comment:
done
--
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]