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

yuqi1129 pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/gravitino.git


The following commit(s) were added to refs/heads/branch-2.0 by this push:
     new 55a7b96be4 [Cherry-pick to branch-2.0] [MINOR] fix(spark-connector): 
Avoid a deprecated StringUtils call that breaks the Spark 4.1 build (#15105) 
(#15107)
55a7b96be4 is described below

commit 55a7b96be41b9399e1d563a6265315c2437f07d3
Author: Jerry Shao <[email protected]>
AuthorDate: Thu Nov 19 15:21:05 2026 +0800

    [Cherry-pick to branch-2.0] [MINOR] fix(spark-connector): Avoid a 
deprecated StringUtils call that breaks the Spark 4.1 build (#15105) (#15107)
    
    **Cherry-pick Information:**
    - Original commit: 9cb34602a77962bac7cac300e643a7665b4bf921
    - Target branch: `branch-2.0`
    - Status: ✅ Clean cherry-pick (no conflicts)
    - Fork CI: runs in `jerryshao/gravitino`; re-run it there or push to
    this PR branch
    
    Co-authored-by: Bharath Krishna <[email protected]>
    Co-authored-by: Claude Sonnet 5.5 <[email protected]>
---
 .../restcatalog/lance/LanceRESTCatalogProvider.java       | 10 ++++++++--
 .../restcatalog/lance/TestLanceRESTCatalogProvider.java   | 15 +++++++++++++++
 2 files changed, 23 insertions(+), 2 deletions(-)

diff --git 
a/spark-connector/spark-common/src/main/java/org/apache/gravitino/spark/connector/plugin/restcatalog/lance/LanceRESTCatalogProvider.java
 
b/spark-connector/spark-common/src/main/java/org/apache/gravitino/spark/connector/plugin/restcatalog/lance/LanceRESTCatalogProvider.java
index 69aebdd452..0587ae76c2 100644
--- 
a/spark-connector/spark-common/src/main/java/org/apache/gravitino/spark/connector/plugin/restcatalog/lance/LanceRESTCatalogProvider.java
+++ 
b/spark-connector/spark-common/src/main/java/org/apache/gravitino/spark/connector/plugin/restcatalog/lance/LanceRESTCatalogProvider.java
@@ -65,7 +65,7 @@ public class LanceRESTCatalogProvider implements 
LakehouseRESTCatalogProvider {
     Map<String, String> headers = new LinkedHashMap<>();
     properties.forEach(
         (key, value) -> {
-          if (StringUtils.startsWithIgnoreCase(key, HEADER_PREFIX)) {
+          if (isHeaderProperty(key)) {
             String headerName = key.substring(HEADER_PREFIX.length());
             Preconditions.checkArgument(
                 headerName.matches("[!#$%&'*+.^_`|~0-9A-Za-z-]+"),
@@ -81,7 +81,7 @@ public class LanceRESTCatalogProvider implements 
LakehouseRESTCatalogProvider {
                 canonicalKey);
           }
         });
-    properties.keySet().removeIf(key -> StringUtils.startsWithIgnoreCase(key, 
HEADER_PREFIX));
+    properties.keySet().removeIf(LanceRESTCatalogProvider::isHeaderProperty);
     properties.putAll(headers);
   }
 
@@ -167,6 +167,12 @@ public class LanceRESTCatalogProvider implements 
LakehouseRESTCatalogProvider {
     return new String[] {SPARK_EXTENSIONS};
   }
 
+  // Avoid StringUtils.startsWithIgnoreCase: deprecated in the commons-lang3 
version used by
+  // Spark 4.1, and the connector compiles with -Werror.
+  private static boolean isHeaderProperty(@Nullable String key) {
+    return key != null && key.regionMatches(true, 0, HEADER_PREFIX, 0, 
HEADER_PREFIX.length());
+  }
+
   /**
    * The Lance client uses the raw response body as the exception message, 
which is empty for most
    * error responses, so fall back to the reason phrase and finally to an 
explicit placeholder
diff --git 
a/spark-connector/spark-common/src/test/java/org/apache/gravitino/spark/connector/plugin/restcatalog/lance/TestLanceRESTCatalogProvider.java
 
b/spark-connector/spark-common/src/test/java/org/apache/gravitino/spark/connector/plugin/restcatalog/lance/TestLanceRESTCatalogProvider.java
index c1e47ab000..eb28741b76 100644
--- 
a/spark-connector/spark-common/src/test/java/org/apache/gravitino/spark/connector/plugin/restcatalog/lance/TestLanceRESTCatalogProvider.java
+++ 
b/spark-connector/spark-common/src/test/java/org/apache/gravitino/spark/connector/plugin/restcatalog/lance/TestLanceRESTCatalogProvider.java
@@ -107,6 +107,21 @@ public class TestLanceRESTCatalogProvider {
     assertTrue(rawQueries.get(0).contains("delimiter=%23"));
   }
 
+  @Test
+  void testNormalizesOnlyHeaderPropertiesCaseInsensitively() {
+    Map<String, String> properties = new LinkedHashMap<>();
+    properties.put(null, "untouched");
+    properties.put("headers", "ordinary property");
+    properties.put("HEADERS.X-Test", "value");
+
+    new LanceRESTCatalogProvider().normalizeCatalogProperties(properties);
+
+    assertEquals("untouched", properties.get(null));
+    assertEquals("ordinary property", properties.get("headers"));
+    assertEquals("value", properties.get("headers.x-test"));
+    assertFalse(properties.containsKey("HEADERS.X-Test"));
+  }
+
   @Test
   void testDiscoverySendsOneAuthorizationValuePerPageForIdenticalHeaders() {
     List<String> authorizationHeaders = new CopyOnWriteArrayList<>();

Reply via email to