This is an automated email from the ASF dual-hosted git repository.

feiwang pushed a commit to branch branch-1.11
in repository https://gitbox.apache.org/repos/asf/kyuubi.git


The following commit(s) were added to refs/heads/branch-1.11 by this push:
     new 51618cb27e [KYUUBI #7317] [KYUUBI-7316] Fix parsePropertyFromUrl to 
remove query string from parsed values
51618cb27e is described below

commit 51618cb27ed3d06f977d42f37f5fb25176f74089
Author: Yuming Wang <[email protected]>
AuthorDate: Thu Feb 12 23:39:50 2026 -0800

    [KYUUBI #7317] [KYUUBI-7316] Fix parsePropertyFromUrl to remove query 
string from parsed values
    
    ### Why are the changes needed?
    
    Fixed the `parsePropertyFromUrl` method in `Utils.java` to properly remove 
query string parts (everything after ?) from parsed JDBC URL property values, 
making it consistent with the `extractURLComponents` method.
    
    When parsing JDBC URLs with query strings like: 
`jdbc:hive2://host:10012/db;auth=JWT?kyuubi.session.cluster=clusterA`.
    The `parsePropertyFromUrl` method was incorrectly returning 
`JWT?kyuubi.session.cluster=clusterA` for the `auth` property, while 
`extractURLComponents` correctly returned only `JWT`. This inconsistency could 
cause authentication failures in JWT auth scenarios with additional query 
parameters.
    
    ### How was this patch tested?
    
    1. URLs with query strings parse properties correctly without the query 
string
    2. URLs without query strings continue to work as expected
    3. Both parsing methods return consistent results
    
    ### Was this patch authored or co-authored using generative AI tooling?
    
    No.
    
    Closes #7317 from wangyum/KYUUBI-7316.
    
    Closes #7317
    
    6b8d3b58d [Yuming Wang] f
    88a3c5a06 [Yuming Wang] fix
    e89260ce1 [Yuming Wang] fix
    206f28d27 [Yuming Wang] fix
    
    Authored-by: Yuming Wang <[email protected]>
    Signed-off-by: Fei Wang <[email protected]>
    (cherry picked from commit c5acf543a01668c9de373681a6c49f6c85d5a1a0)
    Signed-off-by: Fei Wang <[email protected]>
---
 .../java/org/apache/kyuubi/jdbc/hive/Utils.java    |  3 +-
 .../org/apache/kyuubi/jdbc/hive/UtilsTest.java     | 39 ++++++++++++++++++++++
 2 files changed, 41 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 c57829a8e0..2567795d95 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
@@ -565,7 +565,8 @@ public class Utils {
   }
 
   public static String parsePropertyFromUrl(final String url, final String 
key) {
-    String[] tokens = url.split(";");
+    String urlClientPropertiesSection = url.split("[?#]")[0];
+    String[] tokens = urlClientPropertiesSection.split(";");
     for (String token : tokens) {
       if (token.trim().startsWith(key.trim() + "=")) {
         return token.trim().substring((key.trim() + "=").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 0c04d4ade9..3566177189 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
@@ -210,4 +210,43 @@ public class UtilsTest {
         splitSql.get(0));
     assertEquals("", splitSql.get(1));
   }
+
+  @Test
+  public void testParsePropertyFromUrlConsistentWithExtractURLComponents()
+      throws JdbcUriParseException {
+    // Test case for JWT auth with query string
+    String url =
+        
"jdbc:hive2://host:10012/access_views;transportMode=http;httpPath=cliservice;"
+            + "ssl=true;auth=JWT?kyuubi.session.cluster=clusterA";
+
+    // Parse using parsePropertyFromUrl
+    String authFromParseProperty = Utils.parsePropertyFromUrl(url, "auth");
+
+    // Parse using extractURLComponents
+    JdbcConnectionParams params = Utils.extractURLComponents(url, new 
Properties());
+    String authFromExtract = params.getSessionVars().get("auth");
+
+    // Both methods should return "JWT", not 
"JWT?kyuubi.session.cluster=clusterA"
+    assertEquals("JWT", authFromParseProperty);
+    assertEquals("JWT", authFromExtract);
+    assertEquals(
+        "parsePropertyFromUrl and extractURLComponents should return the same 
auth value",
+        authFromExtract,
+        authFromParseProperty);
+
+    // Verify query string parameters are correctly parsed
+    assertEquals("clusterA", 
params.getHiveConfs().get("kyuubi.session.cluster"));
+  }
+
+  @Test
+  public void testParsePropertyFromUrlWithoutQueryString() {
+    // Test case without query string
+    String url = 
"jdbc:hive2://localhost:10009/db;auth=KERBEROS;transportMode=binary";
+
+    String authValue = Utils.parsePropertyFromUrl(url, "auth");
+    assertEquals("KERBEROS", authValue);
+
+    String transportMode = Utils.parsePropertyFromUrl(url, "transportMode");
+    assertEquals("binary", transportMode);
+  }
 }

Reply via email to