You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flink.apache.org by gy...@apache.org on 2022/02/23 13:06:52 UTC

[flink-kubernetes-operator] branch main updated: [FLINK-26329] Adjust the order of var initialization in FlinkControllerConfig

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

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


The following commit(s) were added to refs/heads/main by this push:
     new eda38b4  [FLINK-26329] Adjust the order of var initialization in FlinkControllerConfig
eda38b4 is described below

commit eda38b49fb5eb8dade08d1096493a49cf5c91872
Author: Junfan Zhang <ju...@outlook.com>
AuthorDate: Wed Feb 23 17:43:59 2022 +0800

    [FLINK-26329] Adjust the order of var initialization in FlinkControllerConfig
    
    Closes #17
---
 .../kubernetes/operator/controller/FlinkControllerConfig.java | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/flink-kubernetes-operator/src/main/java/org/apache/flink/kubernetes/operator/controller/FlinkControllerConfig.java b/flink-kubernetes-operator/src/main/java/org/apache/flink/kubernetes/operator/controller/FlinkControllerConfig.java
index 1cfdab5..126347f 100644
--- a/flink-kubernetes-operator/src/main/java/org/apache/flink/kubernetes/operator/controller/FlinkControllerConfig.java
+++ b/flink-kubernetes-operator/src/main/java/org/apache/flink/kubernetes/operator/controller/FlinkControllerConfig.java
@@ -22,27 +22,30 @@ import org.apache.flink.kubernetes.operator.crd.FlinkDeployment;
 import io.javaoperatorsdk.operator.config.runtime.AnnotationConfiguration;
 import org.apache.commons.lang3.StringUtils;
 
+import java.util.Collections;
 import java.util.HashSet;
 import java.util.Set;
 
 /** Custom config for {@link FlinkDeploymentController}. */
 public class FlinkControllerConfig extends AnnotationConfiguration<FlinkDeployment> {
 
-    public static final String ENV_WATCHED_NAMESPACES = "FLINK_OPERATOR_WATCH_NAMESPACES";
+    private static final String ENV_WATCHED_NAMESPACES = "FLINK_OPERATOR_WATCH_NAMESPACES";
+    private static final String NAMESPACES_SPLITTER_KEY = ",";
 
     public FlinkControllerConfig(FlinkDeploymentController reconciler) {
         super(reconciler);
     }
 
+    @Override
     public Set<String> getNamespaces() {
         String watchedNamespaces = System.getenv(ENV_WATCHED_NAMESPACES);
-        Set<String> namespaces = new HashSet<>();
 
         if (StringUtils.isEmpty(watchedNamespaces)) {
-            return namespaces;
+            return Collections.emptySet();
         }
 
-        for (String ns : watchedNamespaces.split(",")) {
+        Set<String> namespaces = new HashSet<>();
+        for (String ns : watchedNamespaces.split(NAMESPACES_SPLITTER_KEY)) {
             namespaces.add(ns);
         }