Copilot commented on code in PR #3592:
URL: https://github.com/apache/maven-surefire/pull/3592#discussion_r4561305135


##########
maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java:
##########
@@ -3532,8 +3532,23 @@ public Map<String, String> getSystemPropertyVariables() {
     }
 
     @SuppressWarnings("UnusedDeclaration")
-    public void setSystemPropertyVariables(Map<String, String> 
systemPropertyVariables) {
-        this.systemPropertyVariables = systemPropertyVariables;
+    public void setSystemPropertyVariables(Map<String, ?> 
systemPropertyVariables) {
+        this.systemPropertyVariables =
+                systemPropertyVariables == null ? null : 
stringifyValues(systemPropertyVariables);
+    }
+
+    /**
+     * Interpolation of a {@code systemPropertyVariables} entry such as {@code 
${settings.offline}} can resolve
+     * to a non-String object (e.g. {@code Boolean}), so the configurator must 
accept {@code Map<String, ?>}
+     * rather than {@code Map<String, String>} and this method stringifies 
every value explicitly.
+     */
+    private static Map<String, String> stringifyValues(Map<String, ?> values) {
+        Map<String, String> result = new HashMap<>();
+        for (Entry<String, ?> entry : values.entrySet()) {
+            Object value = entry.getValue();
+            result.put(entry.getKey(), value == null ? null : 
String.valueOf(value));
+        }
+        return result;

Review Comment:
   stringifyValues() currently copies into a plain HashMap, which can drop the 
caller’s iteration order. If any downstream behavior/logging relies on 
deterministic iteration, prefer preserving the input order by using a 
LinkedHashMap (and optionally sizing it from values.size() to avoid rehashes).



-- 
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