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

zuston pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-uniffle.git


The following commit(s) were added to refs/heads/master by this push:
     new d9b1d9fba [#1721] fix(coordinator): classCastExpection of 
boolean->String with yaml style remote client conf (#1722)
d9b1d9fba is described below

commit d9b1d9fba58f70347ec2a352f15502eeec53deb9
Author: Junfan Zhang <[email protected]>
AuthorDate: Tue May 21 09:59:22 2024 +0800

    [#1721] fix(coordinator): classCastExpection of boolean->String with yaml 
style remote client conf (#1722)
    
    ### What changes were proposed in this pull request?
    
    fix classCastExpection of boolean->String with yaml style remote client conf
    
    ### Why are the changes needed?
    
    Fix: #1721
    
    ### Does this PR introduce _any_ user-facing change?
    
    
    No.
    
    ### How was this patch tested?
    
    Unit tests
---
 .../org/apache/uniffle/coordinator/conf/YamlClientConfParser.java  | 7 ++++++-
 .../apache/uniffle/coordinator/conf/YamlClientConfParserTest.java  | 5 +++++
 coordinator/src/test/resources/dynamicClientConf.yaml              | 4 ++++
 3 files changed, 15 insertions(+), 1 deletion(-)

diff --git 
a/coordinator/src/main/java/org/apache/uniffle/coordinator/conf/YamlClientConfParser.java
 
b/coordinator/src/main/java/org/apache/uniffle/coordinator/conf/YamlClientConfParser.java
index 84841a3a6..d34a6b683 100644
--- 
a/coordinator/src/main/java/org/apache/uniffle/coordinator/conf/YamlClientConfParser.java
+++ 
b/coordinator/src/main/java/org/apache/uniffle/coordinator/conf/YamlClientConfParser.java
@@ -22,6 +22,7 @@ import java.nio.charset.StandardCharsets;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
+import java.util.stream.Collectors;
 
 import org.apache.commons.io.IOUtils;
 import org.apache.hadoop.conf.Configuration;
@@ -58,7 +59,11 @@ public class YamlClientConfParser implements 
ClientConfParser {
 
   private Map<String, String> parseKVItems(Object confRaw) throws Exception {
     if (confRaw instanceof Map) {
-      return (Map<String, String>) confRaw;
+      return ((Map<?, ?>) confRaw)
+          .entrySet().stream()
+              .collect(
+                  Collectors.toMap(
+                      x -> String.valueOf(x.getKey()), x -> 
String.valueOf(x.getValue())));
     }
 
     // todo: currently only xml format is supported
diff --git 
a/coordinator/src/test/java/org/apache/uniffle/coordinator/conf/YamlClientConfParserTest.java
 
b/coordinator/src/test/java/org/apache/uniffle/coordinator/conf/YamlClientConfParserTest.java
index 00133e0cb..df4d57a29 100644
--- 
a/coordinator/src/test/java/org/apache/uniffle/coordinator/conf/YamlClientConfParserTest.java
+++ 
b/coordinator/src/test/java/org/apache/uniffle/coordinator/conf/YamlClientConfParserTest.java
@@ -32,6 +32,11 @@ public class YamlClientConfParserTest {
             
getClass().getClassLoader().getResource("dynamicClientConf.yaml").openStream());
     assertEquals("v1", conf.getRssClientConf().get("k1"));
     assertEquals("v2", conf.getRssClientConf().get("k2"));
+    assertEquals("true", conf.getRssClientConf().get("k3"));
+    assertEquals("false", conf.getRssClientConf().get("k4"));
+    assertEquals("1", conf.getRssClientConf().get("k5"));
+    assertEquals("2", conf.getRssClientConf().get("k6"));
+
     assertEquals(
         "v1,v2,v3", 
conf.getRemoteStorageInfos().get("hdfs://a-ns01").getConfItems().get("k1"));
     assertEquals("v1", 
conf.getRemoteStorageInfos().get("hdfs://x-ns01").getConfItems().get("k1"));
diff --git a/coordinator/src/test/resources/dynamicClientConf.yaml 
b/coordinator/src/test/resources/dynamicClientConf.yaml
index 44de0ac7e..f0f5a7dc3 100644
--- a/coordinator/src/test/resources/dynamicClientConf.yaml
+++ b/coordinator/src/test/resources/dynamicClientConf.yaml
@@ -18,6 +18,10 @@
 rssClientConf:
   k1: v1
   k2: v2
+  k3: true
+  k4: false
+  k5: 1
+  k6: 2
 
 remoteStorageInfos:
   hdfs://a-ns01: |+

Reply via email to