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

benjobs pushed a commit to branch dev-2.1.2
in repository https://gitbox.apache.org/repos/asf/incubator-streampark.git


The following commit(s) were added to refs/heads/dev-2.1.2 by this push:
     new 39e9dc300 minor improvement
39e9dc300 is described below

commit 39e9dc30028b131f9d3fb8da7ee1147f4b9e1838
Author: benjobs <[email protected]>
AuthorDate: Thu Oct 5 17:44:09 2023 +0800

    minor improvement
---
 .../apache/streampark/common/util/PropertiesUtils.scala  | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git 
a/streampark-common/src/main/scala/org/apache/streampark/common/util/PropertiesUtils.scala
 
b/streampark-common/src/main/scala/org/apache/streampark/common/util/PropertiesUtils.scala
index 75ab3ceff..544314801 100644
--- 
a/streampark-common/src/main/scala/org/apache/streampark/common/util/PropertiesUtils.scala
+++ 
b/streampark-common/src/main/scala/org/apache/streampark/common/util/PropertiesUtils.scala
@@ -53,19 +53,19 @@ object PropertiesUtils extends Logger {
     buffer.toString()
   }
 
-  private[this] def eachAppendYamlItem(
-      prefix: String,
+  private[this] def eachYamlItem(
       k: String,
       v: Any,
-      proper: collection.mutable.Map[String, String]): Map[String, String] = {
+      prefix: String = "",
+      proper: MutableMap[String, String] = MutableMap[String, String]()): 
Map[String, String] = {
     v match {
       case map: JavaLinkedMap[String, Any] =>
         map
           .flatMap(
             x => {
               prefix match {
-                case "" => eachAppendYamlItem(k, x._1, x._2, proper)
-                case other => eachAppendYamlItem(s"$other.$k", x._1, x._2, 
proper)
+                case "" => eachYamlItem(x._1, x._2, k, proper)
+                case other => eachYamlItem(x._1, x._2, s"$other.$k", proper)
               }
             })
           .toMap
@@ -84,11 +84,10 @@ object PropertiesUtils extends Logger {
 
   def fromYamlText(text: String): Map[String, String] = {
     try {
-      val map = MutableMap[String, String]()
       new Yaml()
         .load(text)
         .asInstanceOf[java.util.Map[String, Map[String, Any]]]
-        .flatMap(x => eachAppendYamlItem("", x._1, x._2, map))
+        .flatMap(x => eachYamlItem(x._1, x._2))
         .toMap
     } catch {
       case e: IOException =>
@@ -148,11 +147,10 @@ object PropertiesUtils extends Logger {
       inputStream != null,
       s"[StreamPark] fromYamlFile: Properties inputStream  must not be null")
     try {
-      val map = MutableMap[String, String]()
       new Yaml()
         .load(inputStream)
         .asInstanceOf[java.util.Map[String, Map[String, Any]]]
-        .flatMap(x => eachAppendYamlItem("", x._1, x._2, map))
+        .flatMap(x => eachYamlItem(x._1, x._2))
         .toMap
     } catch {
       case e: IOException =>

Reply via email to