Problem description

Repository demonstrating issue: https://github.com/smurf667/spring-boot-maven-plugin-aot-sysprop-quotes Spring Boot version: 3.5.4 Maven version: 3.9.8 JDK: Eclipse Temurin 21 OS affected: Linux OS unaffected: Windows

Using spring-boot-maven-plugin with Spring AOT (specifically the process-aot goal), system properties configured via <systemPropertyVariables> are quoted in the generated command line as follows:

return String.format("-D%s=\"%s\"", key, value);

This behavior breaks environment variable substitution when running on Linux. Specifically, system properties fail to resolve properly when set via pom.xml. In this case, the value is surrounded with double quotes at runtime, affecting behavior; no quotes are expected.

Hypothesis

Windows' command-line parsing strips the outer quotes, but Linux preserves them, causing Spring's property resolution to fail. When the value hello is configured, the quoted value "hello" is treated literally, rather than hello.

Comment From: mhalbritter

I wonder why we quote those system properties at all. Usually we need to quote stuff when passing values with spaces to a shell, but we pass them to a ProcessBuilder here.

ProcessBuilder pb = new ProcessBuilder();
pb.command().addAll(List.of("java", "-Dtest=value with spaces", "-jar", "app.jar"));

where app.jar contains this main method:

System.out.println("'" + System.getProperty("test") + "'");

Prints

'value with spaces'

Comment From: wilkinsona

I think it might be due to some round-tripping (that I'm not sure is necessary) with RunArguments. An instance is created by joining the arguments into a space-separated String:

https://github.com/spring-projects/spring-boot/blob/e70edced2f4dbc789d0ed3ccb990cb616d2b9bad/build-plugin/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/AbstractRunMojo.java#L312-L324

It's then parsed back into separate arguments:

https://github.com/spring-projects/spring-boot/blob/e70edced2f4dbc789d0ed3ccb990cb616d2b9bad/build-plugin/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/RunArguments.java#L56-L67

AFAICT, translateCommandline respects the " characters to keep space-separated words all part of the same argument when they're surrounded by quotes.