xintongsong commented on a change in pull request #16821:
URL: https://github.com/apache/flink/pull/16821#discussion_r724660924



##########
File path: 
flink-core/src/main/java/org/apache/flink/configuration/CoreOptions.java
##########
@@ -127,9 +149,13 @@
                                     + "thrown while trying to load a user code 
class.");
 
     public static String[] getParentFirstLoaderPatterns(Configuration config) {
-        String base = config.getString(ALWAYS_PARENT_FIRST_LOADER_PATTERNS);
-        String append = 
config.getString(ALWAYS_PARENT_FIRST_LOADER_PATTERNS_ADDITIONAL);
-        return parseParentFirstLoaderPatterns(base, append);
+        List<String> base =
+                ConfigUtils.decodeListFromConfig(
+                        config, ALWAYS_PARENT_FIRST_LOADER_PATTERNS, 
String::new);
+        List<String> append =
+                ConfigUtils.decodeListFromConfig(
+                        config, 
ALWAYS_PARENT_FIRST_LOADER_PATTERNS_ADDITIONAL, String::new);

Review comment:
       ```suggestion
           List<String> base = config.get(ALWAYS_PARENT_FIRST_LOADER_PATTERNS);
           List<String> append = 
config.get(ALWAYS_PARENT_FIRST_LOADER_PATTERNS_ADDITIONAL);
   ```

##########
File path: 
flink-core/src/main/java/org/apache/flink/configuration/CoreOptions.java
##########
@@ -94,24 +101,39 @@
      * </ul>
      */
     @Documentation.Section(Documentation.Sections.EXPERT_CLASS_LOADING)
-    public static final ConfigOption<String> 
ALWAYS_PARENT_FIRST_LOADER_PATTERNS =
+    public static final ConfigOption<List<String>> 
ALWAYS_PARENT_FIRST_LOADER_PATTERNS =
             ConfigOptions.key("classloader.parent-first-patterns.default")
-                    .defaultValue(
-                            
"java.;scala.;org.apache.flink.;com.esotericsoftware.kryo;org.apache.hadoop.;javax.annotation.;org.xml;javax.xml;org.apache.xerces;org.w3c;"
-                                    + PARENT_FIRST_LOGGING_PATTERNS)
+                    .stringType()
+                    .asList()
+                    .defaultValues(
+                            mergeListsToArray(
+                                    Arrays.asList(
+                                            "java.",
+                                            "scala.",
+                                            "org.apache.flink.",
+                                            "com.esotericsoftware.kryo",
+                                            "org.apache.hadoop.",
+                                            "javax.annotation.",
+                                            "org.xml",
+                                            "javax.xml",
+                                            "org.apache.xerces",
+                                            "org.w3c"),
+                                    PARENT_FIRST_LOGGING_PATTERNS))
                     .withDeprecatedKeys("classloader.parent-first-patterns")
                     .withDescription(
-                            "A (semicolon-separated) list of patterns that 
specifies which classes should always be"
+                            "A list of patterns that specifies which classes 
should always be"

Review comment:
       No need to remove `(semicolon-separated)`. It's a good hint for users on 
how to format a list type config option.

##########
File path: 
flink-core/src/main/java/org/apache/flink/configuration/CoreOptions.java
##########
@@ -36,8 +38,13 @@
 public class CoreOptions {
 
     @Internal
-    public static final String PARENT_FIRST_LOGGING_PATTERNS =
-            
"org.slf4j;org.apache.log4j;org.apache.logging;org.apache.commons.logging;ch.qos.logback";
+    public static final List<String> PARENT_FIRST_LOGGING_PATTERNS =
+            Arrays.asList(
+                    "org.slf4j",
+                    "org.apache.log4j",
+                    "org.apache.logging",
+                    "org.apache.commons.logging",
+                    "ch.qos.logback");

Review comment:
       You can save a lot of conversions between list and array by making this 
a `String[]`.
   Because `defaultValues()` only takes arrays. The only thing you need would 
be `ArrayUtils.concat()` for merging two arrays. `mergeListsToArray` will not 
be necessary.

##########
File path: 
flink-core/src/main/java/org/apache/flink/configuration/CoreOptions.java
##########
@@ -151,43 +177,50 @@
     @Documentation.ExcludeFromDocumentation(
             "Plugin classloader list is considered an implementation detail. "
                     + "Configuration only included in case to mitigate 
unintended side-effects of this young feature.")
-    public static final ConfigOption<String> 
PLUGIN_ALWAYS_PARENT_FIRST_LOADER_PATTERNS =
+    public static final ConfigOption<List<String>> 
PLUGIN_ALWAYS_PARENT_FIRST_LOADER_PATTERNS =
             
ConfigOptions.key("plugin.classloader.parent-first-patterns.default")
                     .stringType()
-                    .defaultValue(
-                            "java.;org.apache.flink.;javax.annotation.;"
-                                    + PARENT_FIRST_LOGGING_PATTERNS)
+                    .asList()
+                    .defaultValues(
+                            mergeListsToArray(
+                                    Arrays.asList(
+                                            "java.", "org.apache.flink.", 
"javax.annotation."),
+                                    PARENT_FIRST_LOGGING_PATTERNS))
                     .withDescription(
-                            "A (semicolon-separated) list of patterns that 
specifies which classes should always be"
+                            "A list of patterns that specifies which classes 
should always be"
                                     + " resolved through the plugin parent 
ClassLoader first. A pattern is a simple prefix that is checked "
                                     + " against the fully qualified class 
name. This setting should generally not be modified. To add another "
                                     + " pattern we recommend to use 
\"plugin.classloader.parent-first-patterns.additional\" instead.");
 
     @Documentation.ExcludeFromDocumentation(
             "Plugin classloader list is considered an implementation detail. "
                     + "Configuration only included in case to mitigate 
unintended side-effects of this young feature.")
-    public static final ConfigOption<String> 
PLUGIN_ALWAYS_PARENT_FIRST_LOADER_PATTERNS_ADDITIONAL =
-            
ConfigOptions.key("plugin.classloader.parent-first-patterns.additional")
-                    .stringType()
-                    .defaultValue("")
-                    .withDescription(
-                            "A (semicolon-separated) list of patterns that 
specifies which classes should always be"
-                                    + " resolved through the plugin parent 
ClassLoader first. A pattern is a simple prefix that is checked "
-                                    + " against the fully qualified class 
name. These patterns are appended to \""
-                                    + 
PLUGIN_ALWAYS_PARENT_FIRST_LOADER_PATTERNS.key()
-                                    + "\".");
+    public static final ConfigOption<List<String>>
+            PLUGIN_ALWAYS_PARENT_FIRST_LOADER_PATTERNS_ADDITIONAL =
+                    
ConfigOptions.key("plugin.classloader.parent-first-patterns.additional")
+                            .stringType()
+                            .asList()
+                            .noDefaultValue()
+                            .withDescription(
+                                    "A list of patterns that specifies which 
classes should always be"

Review comment:
       Same here for `(semicolon-separated)`.

##########
File path: 
flink-core/src/main/java/org/apache/flink/configuration/CoreOptions.java
##########
@@ -151,43 +177,50 @@
     @Documentation.ExcludeFromDocumentation(
             "Plugin classloader list is considered an implementation detail. "
                     + "Configuration only included in case to mitigate 
unintended side-effects of this young feature.")
-    public static final ConfigOption<String> 
PLUGIN_ALWAYS_PARENT_FIRST_LOADER_PATTERNS =
+    public static final ConfigOption<List<String>> 
PLUGIN_ALWAYS_PARENT_FIRST_LOADER_PATTERNS =
             
ConfigOptions.key("plugin.classloader.parent-first-patterns.default")
                     .stringType()
-                    .defaultValue(
-                            "java.;org.apache.flink.;javax.annotation.;"
-                                    + PARENT_FIRST_LOGGING_PATTERNS)
+                    .asList()
+                    .defaultValues(
+                            mergeListsToArray(
+                                    Arrays.asList(
+                                            "java.", "org.apache.flink.", 
"javax.annotation."),
+                                    PARENT_FIRST_LOGGING_PATTERNS))
                     .withDescription(
-                            "A (semicolon-separated) list of patterns that 
specifies which classes should always be"
+                            "A list of patterns that specifies which classes 
should always be"
                                     + " resolved through the plugin parent 
ClassLoader first. A pattern is a simple prefix that is checked "
                                     + " against the fully qualified class 
name. This setting should generally not be modified. To add another "
                                     + " pattern we recommend to use 
\"plugin.classloader.parent-first-patterns.additional\" instead.");
 
     @Documentation.ExcludeFromDocumentation(
             "Plugin classloader list is considered an implementation detail. "
                     + "Configuration only included in case to mitigate 
unintended side-effects of this young feature.")
-    public static final ConfigOption<String> 
PLUGIN_ALWAYS_PARENT_FIRST_LOADER_PATTERNS_ADDITIONAL =
-            
ConfigOptions.key("plugin.classloader.parent-first-patterns.additional")
-                    .stringType()
-                    .defaultValue("")
-                    .withDescription(
-                            "A (semicolon-separated) list of patterns that 
specifies which classes should always be"
-                                    + " resolved through the plugin parent 
ClassLoader first. A pattern is a simple prefix that is checked "
-                                    + " against the fully qualified class 
name. These patterns are appended to \""
-                                    + 
PLUGIN_ALWAYS_PARENT_FIRST_LOADER_PATTERNS.key()
-                                    + "\".");
+    public static final ConfigOption<List<String>>
+            PLUGIN_ALWAYS_PARENT_FIRST_LOADER_PATTERNS_ADDITIONAL =
+                    
ConfigOptions.key("plugin.classloader.parent-first-patterns.additional")
+                            .stringType()
+                            .asList()
+                            .noDefaultValue()

Review comment:
       Same here for default values.

##########
File path: 
flink-core/src/main/java/org/apache/flink/configuration/CoreOptions.java
##########
@@ -151,43 +177,50 @@
     @Documentation.ExcludeFromDocumentation(
             "Plugin classloader list is considered an implementation detail. "
                     + "Configuration only included in case to mitigate 
unintended side-effects of this young feature.")
-    public static final ConfigOption<String> 
PLUGIN_ALWAYS_PARENT_FIRST_LOADER_PATTERNS =
+    public static final ConfigOption<List<String>> 
PLUGIN_ALWAYS_PARENT_FIRST_LOADER_PATTERNS =
             
ConfigOptions.key("plugin.classloader.parent-first-patterns.default")
                     .stringType()
-                    .defaultValue(
-                            "java.;org.apache.flink.;javax.annotation.;"
-                                    + PARENT_FIRST_LOGGING_PATTERNS)
+                    .asList()
+                    .defaultValues(
+                            mergeListsToArray(
+                                    Arrays.asList(
+                                            "java.", "org.apache.flink.", 
"javax.annotation."),
+                                    PARENT_FIRST_LOGGING_PATTERNS))
                     .withDescription(
-                            "A (semicolon-separated) list of patterns that 
specifies which classes should always be"
+                            "A list of patterns that specifies which classes 
should always be"
                                     + " resolved through the plugin parent 
ClassLoader first. A pattern is a simple prefix that is checked "
                                     + " against the fully qualified class 
name. This setting should generally not be modified. To add another "
                                     + " pattern we recommend to use 
\"plugin.classloader.parent-first-patterns.additional\" instead.");
 
     @Documentation.ExcludeFromDocumentation(
             "Plugin classloader list is considered an implementation detail. "
                     + "Configuration only included in case to mitigate 
unintended side-effects of this young feature.")
-    public static final ConfigOption<String> 
PLUGIN_ALWAYS_PARENT_FIRST_LOADER_PATTERNS_ADDITIONAL =
-            
ConfigOptions.key("plugin.classloader.parent-first-patterns.additional")
-                    .stringType()
-                    .defaultValue("")
-                    .withDescription(
-                            "A (semicolon-separated) list of patterns that 
specifies which classes should always be"
-                                    + " resolved through the plugin parent 
ClassLoader first. A pattern is a simple prefix that is checked "
-                                    + " against the fully qualified class 
name. These patterns are appended to \""
-                                    + 
PLUGIN_ALWAYS_PARENT_FIRST_LOADER_PATTERNS.key()
-                                    + "\".");
+    public static final ConfigOption<List<String>>
+            PLUGIN_ALWAYS_PARENT_FIRST_LOADER_PATTERNS_ADDITIONAL =
+                    
ConfigOptions.key("plugin.classloader.parent-first-patterns.additional")
+                            .stringType()
+                            .asList()
+                            .noDefaultValue()
+                            .withDescription(
+                                    "A list of patterns that specifies which 
classes should always be"
+                                            + " resolved through the plugin 
parent ClassLoader first. A pattern is a simple prefix that is checked "
+                                            + " against the fully qualified 
class name. These patterns are appended to \""
+                                            + 
PLUGIN_ALWAYS_PARENT_FIRST_LOADER_PATTERNS.key()
+                                            + "\".");
 
     public static String[] getPluginParentFirstLoaderPatterns(Configuration 
config) {
-        String base = 
config.getString(PLUGIN_ALWAYS_PARENT_FIRST_LOADER_PATTERNS);
-        String append = 
config.getString(PLUGIN_ALWAYS_PARENT_FIRST_LOADER_PATTERNS_ADDITIONAL);
-        return parseParentFirstLoaderPatterns(base, append);
+        List<String> base =
+                ConfigUtils.decodeListFromConfig(
+                        config, PLUGIN_ALWAYS_PARENT_FIRST_LOADER_PATTERNS, 
String::new);
+        List<String> append =
+                ConfigUtils.decodeListFromConfig(
+                        config, 
PLUGIN_ALWAYS_PARENT_FIRST_LOADER_PATTERNS_ADDITIONAL, String::new);

Review comment:
       ```suggestion
           List<String> base = 
config.get(PLUGIN_ALWAYS_PARENT_FIRST_LOADER_PATTERNS);
           List<String> append = 
config.get(PLUGIN_ALWAYS_PARENT_FIRST_LOADER_PATTERNS_ADDITIONAL);
   ```

##########
File path: 
flink-core/src/main/java/org/apache/flink/configuration/CoreOptions.java
##########
@@ -151,43 +177,50 @@
     @Documentation.ExcludeFromDocumentation(
             "Plugin classloader list is considered an implementation detail. "
                     + "Configuration only included in case to mitigate 
unintended side-effects of this young feature.")
-    public static final ConfigOption<String> 
PLUGIN_ALWAYS_PARENT_FIRST_LOADER_PATTERNS =
+    public static final ConfigOption<List<String>> 
PLUGIN_ALWAYS_PARENT_FIRST_LOADER_PATTERNS =
             
ConfigOptions.key("plugin.classloader.parent-first-patterns.default")
                     .stringType()
-                    .defaultValue(
-                            "java.;org.apache.flink.;javax.annotation.;"
-                                    + PARENT_FIRST_LOGGING_PATTERNS)
+                    .asList()
+                    .defaultValues(
+                            mergeListsToArray(
+                                    Arrays.asList(
+                                            "java.", "org.apache.flink.", 
"javax.annotation."),
+                                    PARENT_FIRST_LOGGING_PATTERNS))
                     .withDescription(
-                            "A (semicolon-separated) list of patterns that 
specifies which classes should always be"
+                            "A list of patterns that specifies which classes 
should always be"

Review comment:
       Same here for `(semicolon-separated)`.

##########
File path: 
flink-core/src/main/java/org/apache/flink/configuration/CoreOptions.java
##########
@@ -94,24 +101,39 @@
      * </ul>
      */
     @Documentation.Section(Documentation.Sections.EXPERT_CLASS_LOADING)
-    public static final ConfigOption<String> 
ALWAYS_PARENT_FIRST_LOADER_PATTERNS =
+    public static final ConfigOption<List<String>> 
ALWAYS_PARENT_FIRST_LOADER_PATTERNS =
             ConfigOptions.key("classloader.parent-first-patterns.default")
-                    .defaultValue(
-                            
"java.;scala.;org.apache.flink.;com.esotericsoftware.kryo;org.apache.hadoop.;javax.annotation.;org.xml;javax.xml;org.apache.xerces;org.w3c;"
-                                    + PARENT_FIRST_LOGGING_PATTERNS)
+                    .stringType()
+                    .asList()
+                    .defaultValues(
+                            mergeListsToArray(
+                                    Arrays.asList(
+                                            "java.",
+                                            "scala.",
+                                            "org.apache.flink.",
+                                            "com.esotericsoftware.kryo",
+                                            "org.apache.hadoop.",
+                                            "javax.annotation.",
+                                            "org.xml",
+                                            "javax.xml",
+                                            "org.apache.xerces",
+                                            "org.w3c"),
+                                    PARENT_FIRST_LOGGING_PATTERNS))
                     .withDeprecatedKeys("classloader.parent-first-patterns")
                     .withDescription(
-                            "A (semicolon-separated) list of patterns that 
specifies which classes should always be"
+                            "A list of patterns that specifies which classes 
should always be"
                                     + " resolved through the parent 
ClassLoader first. A pattern is a simple prefix that is checked against"
                                     + " the fully qualified class name. This 
setting should generally not be modified. To add another pattern we"
                                     + " recommend to use 
\"classloader.parent-first-patterns.additional\" instead.");
 
     @Documentation.Section(Documentation.Sections.EXPERT_CLASS_LOADING)
-    public static final ConfigOption<String> 
ALWAYS_PARENT_FIRST_LOADER_PATTERNS_ADDITIONAL =
+    public static final ConfigOption<List<String>> 
ALWAYS_PARENT_FIRST_LOADER_PATTERNS_ADDITIONAL =
             ConfigOptions.key("classloader.parent-first-patterns.additional")
-                    .defaultValue("")
+                    .stringType()
+                    .asList()
+                    .noDefaultValue()

Review comment:
       ```suggestion
                       .defaultValues()
   ```
   Default value should be an empty list. Otherwise, it returns `null` for this 
option when it's not specified, which can easily lead to NPE.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@flink.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to