This is an automated email from the ASF dual-hosted git repository.
chengpan pushed a commit to branch branch-1.8
in repository https://gitbox.apache.org/repos/asf/kyuubi.git
The following commit(s) were added to refs/heads/branch-1.8 by this push:
new 664296250 [KYUUBI #5849] Incorrectly parse JDBC URL while variable
includes colon
664296250 is described below
commit 6642962507bd36b814d17ad2b36f59a6790364ad
Author: wangzeyu <[email protected]>
AuthorDate: Wed Dec 13 15:19:37 2023 +0800
[KYUUBI #5849] Incorrectly parse JDBC URL while variable includes colon
# :mag: Description
## Issue References ๐
This pull request fixes #5849
## Describe Your Solution ๐ง
When replacing the `host:port` information in the jdbc url, only the first
matching string should be replaced.
## Types of changes :bookmark:
- [x] Bugfix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to change)
## Test Plan ๐งช
#### Behavior Without This Pull Request :coffin:
#### Behavior With This Pull Request :tada:
#### Related Unit Tests
---
# Checklists
## ๐ Author Self Checklist
- [x] My code follows the [style
guidelines](https://kyuubi.readthedocs.io/en/master/contributing/code/style.html)
of this project
- [x] I have performed a self-review
- [x] I have commented my code, particularly in hard-to-understand areas
- [x] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [x] I have added tests that prove my fix is effective or that my feature
works
- [x] New and existing unit tests pass locally with my changes
- [x] This patch was not authored or co-authored using [Generative
Tooling](https://www.apache.org/legal/generative-tooling.html)
## ๐ Committer Pre-Merge Checklist
- [x] Pull request title is okay.
- [x] No license issues.
- [x] Milestone correctly set?
- [x] Test coverage is ok
- [x] Assignees are selected.
- [x] Minimum number of approvals
- [x] No changes are requested
**Be nice. Be informative.**
Closes #5850 from hameizi/fix-url-parse.
Closes #5849
491407860 [wangzeyu] fix code style
32565f272 [wangzeyu] fix unit test
e1e6d0a63 [wangzeyu] add unit test
9af1d0596 [wangzeyu] fix
Authored-by: wangzeyu <[email protected]>
Signed-off-by: Cheng Pan <[email protected]>
(cherry picked from commit 1b36ee5b08c066db67ac4e8507030f871880cfa2)
Signed-off-by: Cheng Pan <[email protected]>
---
.../src/main/java/org/apache/kyuubi/jdbc/hive/Utils.java | 2 +-
.../src/test/java/org/apache/kyuubi/jdbc/hive/UtilsTest.java | 11 +++++++++++
2 files changed, 12 insertions(+), 1 deletion(-)
diff --git
a/kyuubi-hive-jdbc/src/main/java/org/apache/kyuubi/jdbc/hive/Utils.java
b/kyuubi-hive-jdbc/src/main/java/org/apache/kyuubi/jdbc/hive/Utils.java
index 135c38d8e..65ad0c41b 100644
--- a/kyuubi-hive-jdbc/src/main/java/org/apache/kyuubi/jdbc/hive/Utils.java
+++ b/kyuubi-hive-jdbc/src/main/java/org/apache/kyuubi/jdbc/hive/Utils.java
@@ -201,7 +201,7 @@ public class Utils {
uri = uri.replace(urlPrefix, urlPrefix + authorityFromClientJdbcURL);
}
connParams.setSuppliedURLAuthority(authorityFromClientJdbcURL);
- uri = uri.replace(authorityFromClientJdbcURL, dummyAuthorityString);
+ uri = uri.replaceFirst(authorityFromClientJdbcURL, dummyAuthorityString);
// Now parse the connection uri with dummy authority
URI jdbcURI = URI.create(uri.substring(URI_JDBC_PREFIX.length()));
diff --git
a/kyuubi-hive-jdbc/src/test/java/org/apache/kyuubi/jdbc/hive/UtilsTest.java
b/kyuubi-hive-jdbc/src/test/java/org/apache/kyuubi/jdbc/hive/UtilsTest.java
index b01957b3e..fc4a55d9f 100644
--- a/kyuubi-hive-jdbc/src/test/java/org/apache/kyuubi/jdbc/hive/UtilsTest.java
+++ b/kyuubi-hive-jdbc/src/test/java/org/apache/kyuubi/jdbc/hive/UtilsTest.java
@@ -111,6 +111,17 @@ public class UtilsTest {
StandardCharsets.UTF_8.toString())
.replaceAll("\\+", "%20")
+ "#k4=v4"
+ },
+ {
+ "hostname",
+ "10018",
+ "catalog",
+ "db",
+ new ImmutableMap.Builder<String, String>()
+ .put("k2", "v2")
+ .put("k3", "hostname:10018")
+ .build(),
+
"jdbc:hive2://hostname:10018/catalog/db;k1=v1?k2=v2;k3=hostname:10018"
}
});
}