Skip to content

Commit 1df9ae4

Browse files
committed
Check for server.port before setting it in sys props
1 parent b50445d commit 1df9ae4

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

spring-boot-testjars/src/main/java/org/springframework/experimental/boot/server/exec/CommonsExecWebServerFactoryBean.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,9 @@ private CommonsExecWebServer build() {
111111
private String[] createSystemPropertyArgs() {
112112
Map<String, String> systemPropertyArgs = new HashMap<>(this.systemProperties);
113113
systemPropertyArgs.put("PORTFILE", this.applicationPortFile.getAbsolutePath());
114-
systemPropertyArgs.put("server.port", "0");
114+
if (!systemPropertyArgs.containsKey("server.port")) {
115+
systemPropertyArgs.put("server.port", "0");
116+
}
115117
return systemPropertyArgs.entrySet().stream().map((e) -> "-D" + e.getKey() + "=" + e.getValue() + "")
116118
.toArray(String[]::new);
117119
}

0 commit comments

Comments
 (0)