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

dongjoon pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/spark-kubernetes-operator.git


The following commit(s) were added to refs/heads/main by this push:
     new 8345db4  [SPARK-52559] Synchronize `SparkOperatorConfManager.getValue`
8345db4 is described below

commit 8345db4f1fdfa76ce94cd28b49bea66b7e12af01
Author: Dongjoon Hyun <[email protected]>
AuthorDate: Mon Jun 23 17:09:04 2025 -0700

    [SPARK-52559] Synchronize `SparkOperatorConfManager.getValue`
    
    ### What changes were proposed in this pull request?
    
    This PR aims to fix a concurrency issue by synchronizing 
`SparkOperatorConfManager.getValue`.
    
    ### Why are the changes needed?
    
    `configOverrides` is supposed by being protected by `this` at `refresh` 
method.
    
    
https://github.com/apache/spark-kubernetes-operator/blob/35214b00c777c724d9cd40208601839824811346/spark-operator/src/main/java/org/apache/spark/k8s/operator/config/SparkOperatorConfManager.java#L71-L76
    
    However, currently `getValue` can access an empty value while `refresh` 
invokes `this.configOverrides = new Properties();` statement because `getValue` 
method is not synchronized properly.
    
    
https://github.com/apache/spark-kubernetes-operator/blob/35214b00c777c724d9cd40208601839824811346/spark-operator/src/main/java/org/apache/spark/k8s/operator/config/SparkOperatorConfManager.java#L62-L65
    
    ### Does this PR introduce _any_ user-facing change?
    
    Yes, this is a bug fix.
    
    ### How was this patch tested?
    
    Manual review. (It's a little difficult to add a concurrency failure test 
case).
    
    ### Was this patch authored or co-authored using generative AI tooling?
    
    No.
    
    Closes #256 from dongjoon-hyun/SPARK-52559.
    
    Authored-by: Dongjoon Hyun <[email protected]>
    Signed-off-by: Dongjoon Hyun <[email protected]>
---
 .../apache/spark/k8s/operator/config/SparkOperatorConfManager.java  | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git 
a/spark-operator/src/main/java/org/apache/spark/k8s/operator/config/SparkOperatorConfManager.java
 
b/spark-operator/src/main/java/org/apache/spark/k8s/operator/config/SparkOperatorConfManager.java
index a3e8e36..13e87a9 100644
--- 
a/spark-operator/src/main/java/org/apache/spark/k8s/operator/config/SparkOperatorConfManager.java
+++ 
b/spark-operator/src/main/java/org/apache/spark/k8s/operator/config/SparkOperatorConfManager.java
@@ -60,8 +60,10 @@ public class SparkOperatorConfManager {
   }
 
   public String getValue(String key) {
-    String currentValue = configOverrides.getProperty(key);
-    return StringUtils.isEmpty(currentValue) ? getInitialValue(key) : 
currentValue;
+    synchronized (this) {
+      String currentValue = configOverrides.getProperty(key);
+      return StringUtils.isEmpty(currentValue) ? getInitialValue(key) : 
currentValue;
+    }
   }
 
   public String getInitialValue(String key) {


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to