Copilot commented on code in PR #29814:
URL: https://github.com/apache/flink/pull/29814#discussion_r4501426942


##########
flink-core/src/main/java/org/apache/flink/configuration/ConfigurationUtils.java:
##########
@@ -47,6 +49,8 @@ public class ConfigurationUtils {
 
     private static final String[] EMPTY = new String[0];
 
+    private static final Pattern LINE_BREAK_PATTERN = 
Pattern.compile("\\s*\\R\\s*");

Review Comment:
   The unanchored leading `\s*` makes `find()` quadratic on a long whitespace 
run without a line break, because it consumes and backtracks through the 
remaining spaces at every starting position. Every flattened string is scanned, 
so even a single-line value with a large whitespace run can delay startup while 
the configuration lock is held. Detect line breaks with `\R` alone and use a 
linear scan to remove surrounding whitespace and join the lines.



##########
flink-core/src/main/java/org/apache/flink/configuration/ConfigurationUtils.java:
##########
@@ -252,11 +257,32 @@ public static List<String> convertConfigToWritableLines(
             return YamlParserUtils.convertAndDumpYamlFromFlatMap(
                     Collections.unmodifiableMap(configuration.confData));
         } else {
-            Map<String, String> fileWritableMap = 
configuration.toFileWritableMap();
-            return fileWritableMap.entrySet().stream()
-                    .map(entry -> entry.getKey() + ": " + entry.getValue())
-                    .collect(Collectors.toList());
+            synchronized (configuration.confData) {
+                return configuration.confData.entrySet().stream()
+                        .map(
+                                entry ->
+                                        entry.getKey()
+                                                + ": "
+                                                + YamlParserUtils.toYAMLString(
+                                                        
joinLines(entry.getValue())))
+                        .collect(Collectors.toList());
+            }

Review Comment:
   Reading `confData` directly bypasses `DelegatingConfiguration`, which stores 
its entries in `backingConfig` and leaves the inherited map empty. Flattening a 
populated delegating configuration now returns an empty list, whereas the 
previous `toFileWritableMap()` call used its override to export the prefixed 
entries. Obtain the raw values through a delegation-aware method such as 
`addAllToProperties()` before joining and dumping them.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to