linghengqian commented on code in PR #35524:
URL: https://github.com/apache/shardingsphere/pull/35524#discussion_r2267045631
##########
infra/database/core/src/main/java/org/apache/shardingsphere/infra/database/core/connector/url/StandardJdbcUrlParser.java:
##########
@@ -56,24 +67,21 @@ public final class StandardJdbcUrlParser {
public JdbcUrl parse(final String jdbcUrl) {
Matcher matcher = CONNECTION_URL_PATTERN.matcher(jdbcUrl);
ShardingSpherePreconditions.checkState(matcher.matches(), () -> new
UnrecognizedDatabaseURLException(jdbcUrl,
CONNECTION_URL_PATTERN.pattern().replaceAll("%", "%%")));
+
String authority = matcher.group(AUTHORITY_GROUP_KEY);
ShardingSpherePreconditions.checkNotNull(authority, () -> new
UnrecognizedDatabaseURLException(jdbcUrl,
CONNECTION_URL_PATTERN.pattern().replaceAll("%", "%%")));
- return new JdbcUrl(parseHostname(authority), parsePort(authority),
matcher.group(PATH_GROUP_KEY),
parseQueryProperties(matcher.group(QUERY_GROUP_KEY)));
+
+ Matcher hostMatcher = HOST_PORT_PATTERN_PATTERN.matcher(authority);
+ ShardingSpherePreconditions.checkState(hostMatcher.find(), () -> new
UnrecognizedDatabaseURLException(jdbcUrl,
CONNECTION_URL_PATTERN.pattern().replaceAll("%", "%%")));
+ return new JdbcUrl(parseHostname(hostMatcher), parsePort(hostMatcher),
matcher.group(PATH_GROUP_KEY),
parseQueryProperties(matcher.group(QUERY_GROUP_KEY)));
Review Comment:
- This PR did not account for the case where `authority` was exactly `""`,
causing integration tests using
`org.apache.shardingsphere.test.natived.jdbc.databases.ClickHouseTest`, and
others, that used `org.testcontainers.jdbc.ContainerDatabaseDriver` to begin
failing. See
https://github.com/apache/shardingsphere/actions/runs/16881168066/job/47817474910
.
```shell
Error: 2025-08-11 13:30:15.744 [main] com.zaxxer.hikari.pool.HikariPool -
HikariPool-1 - Exception during pool initialization.
org.apache.shardingsphere.infra.database.core.exception.UnrecognizedDatabaseURLException:
The URL
`jdbc:tc:clickhouse:25.6.5.41:///demo_ds_2?TC_INITSCRIPT=test-native/sql/clickhouse-init.sql`
is not recognized, please refer to the pattern
`(?<schema>[\w-.+:%%]+)\s*(?://(?<authority>[^/?#]*))?\s*(?:/(?!\s*/)(?<path>[^?#]*))?(?:\?(?!\s*\?)(?<query>[^#]*))?`.
at
org.apache.shardingsphere.infra.database.core.connector.url.StandardJdbcUrlParser.lambda$parse$2(StandardJdbcUrlParser.java:73)
at
org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions.checkState(ShardingSpherePreconditions.java:44)
at
org.apache.shardingsphere.infra.database.core.connector.url.StandardJdbcUrlParser.parse(StandardJdbcUrlParser.java:73)
at
org.apache.shardingsphere.infra.database.clickhouse.connector.ClickHouseConnectionPropertiesParser.parse(ClickHouseConnectionPropertiesParser.java:37)
```
- I've opened PR #36259 to fix the integration issue with
`org.testcontainers.jdbc.ContainerDatabaseDriver`.
--
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]