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

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


The following commit(s) were added to refs/heads/dev-2.1.5 by this push:
     new 061e34b75 [Improve] configHolder get value bug fixed. (#3993)
061e34b75 is described below

commit 061e34b75545e1bc961e63aefa446eda233d76bb
Author: benjobs <[email protected]>
AuthorDate: Sat Aug 24 18:30:40 2024 +0800

    [Improve] configHolder get value bug fixed. (#3993)
---
 .../common/conf/InternalConfigHolder.scala           | 20 +++++++++++++-------
 .../console/core/runner/EnvInitializer.java          |  1 +
 2 files changed, 14 insertions(+), 7 deletions(-)

diff --git 
a/streampark-common/src/main/scala/org/apache/streampark/common/conf/InternalConfigHolder.scala
 
b/streampark-common/src/main/scala/org/apache/streampark/common/conf/InternalConfigHolder.scala
index e06a900a3..14cdec69f 100644
--- 
a/streampark-common/src/main/scala/org/apache/streampark/common/conf/InternalConfigHolder.scala
+++ 
b/streampark-common/src/main/scala/org/apache/streampark/common/conf/InternalConfigHolder.scala
@@ -43,7 +43,7 @@ object InternalConfigHolder extends Logger {
   private val confOptions = new ConcurrentHashMap[String, 
InternalOption](initialCapacity)
 
   /** Initialize the ConfigHub. */
-  {
+  def initConfigHub(): Unit = {
     Seq(CommonConfig, K8sFlinkConfig)
   }
 
@@ -68,13 +68,19 @@ object InternalConfigHolder extends Logger {
    */
   @Nonnull
   def get[T](@Nonnull conf: InternalOption): T = {
-    confData.get(conf.key) match {
-      case null =>
-        SystemPropertyUtils.get(conf.key) match {
-          case v if v != null => v.cast[T](conf.classType)
-          case _ => conf.defaultValue.asInstanceOf[T]
+    val value = confData.get(conf.key)
+    if (value == null || value == conf.defaultValue) {
+      val v = SystemPropertyUtils.get(conf.key)
+      if (v != null) {
+        if (v != value) {
+          set(conf, v)
         }
-      case v: T => v
+        v.cast[T](conf.classType)
+      } else {
+        conf.defaultValue.asInstanceOf[T]
+      }
+    } else {
+      value.toString.cast[T](conf.classType)
     }
   }
 
diff --git 
a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/runner/EnvInitializer.java
 
b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/runner/EnvInitializer.java
index 88d345a06..184105e11 100644
--- 
a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/runner/EnvInitializer.java
+++ 
b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/runner/EnvInitializer.java
@@ -97,6 +97,7 @@ public class EnvInitializer implements ApplicationRunner {
   }
 
   private void initInternalConfig(Environment springEnv) {
+    InternalConfigHolder.initConfigHub();
     // override config from spring application.yaml
     InternalConfigHolder.keys().stream()
         .filter(springEnv::containsProperty)

Reply via email to