Skip to content

Commit 64860e1

Browse files
committed
Improve diagnostics when forked JVM exits with non-zero status
Closes gh-16869
1 parent 2afc8af commit 64860e1

File tree

1 file changed

+11
-6
lines changed
  • spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven

1 file changed

+11
-6
lines changed

spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/RunMojo.java

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,17 +69,22 @@ protected void logDisabledFork() {
6969
@Override
7070
protected void runWithForkedJvm(File workingDirectory, List<String> args,
7171
Map<String, String> environmentVariables) throws MojoExecutionException {
72+
int exitCode = forkJvm(workingDirectory, args, environmentVariables);
73+
if (exitCode == 0 || exitCode == EXIT_CODE_SIGINT) {
74+
return;
75+
}
76+
throw new MojoExecutionException(
77+
"Application finished with exit code: " + exitCode);
78+
}
79+
80+
private int forkJvm(File workingDirectory, List<String> args,
81+
Map<String, String> environmentVariables) throws MojoExecutionException {
7282
try {
7383
RunProcess runProcess = new RunProcess(workingDirectory,
7484
new JavaExecutable().toString());
7585
Runtime.getRuntime()
7686
.addShutdownHook(new Thread(new RunProcessKiller(runProcess)));
77-
int exitCode = runProcess.run(true, args, environmentVariables);
78-
if (exitCode == 0 || exitCode == EXIT_CODE_SIGINT) {
79-
return;
80-
}
81-
throw new MojoExecutionException(
82-
"Application finished with exit code: " + exitCode);
87+
return runProcess.run(true, args, environmentVariables);
8388
}
8489
catch (Exception ex) {
8590
throw new MojoExecutionException("Could not exec java", ex);

0 commit comments

Comments
 (0)