Commit b3e0b3a5 authored by Andy Wilkinson's avatar Andy Wilkinson

Consider mvn spring-boot:run that exits with 130 (SIGINT) to be successful

Previously, if mvn spring-boot:run with a forked JVM was killed with 
CTRL+C, the run would be considered unsuccessful. This commits updates
the run mojo to consider a forked JVM that exists with 130 (the exit
code produced when exiting due to SIGINT which is what CTRL+C sends) to
be successful.

Closes gh-6498
parent 79b0d145
......@@ -39,6 +39,8 @@ import org.springframework.boot.loader.tools.RunProcess;
@Execute(phase = LifecyclePhase.TEST_COMPILE)
public class RunMojo extends AbstractRunMojo {
private static final int EXIT_CODE_SIGINT = 130;
@Override
protected void runWithForkedJvm(List<String> args) throws MojoExecutionException {
try {
......@@ -46,11 +48,11 @@ public class RunMojo extends AbstractRunMojo {
Runtime.getRuntime()
.addShutdownHook(new Thread(new RunProcessKiller(runProcess)));
int exitCode = runProcess.run(true, args.toArray(new String[args.size()]));
if (exitCode != 0) {
throw new MojoExecutionException(
"Application finished with non-zero exit code: " + exitCode);
if (exitCode == 0 || exitCode == EXIT_CODE_SIGINT) {
return;
}
throw new MojoExecutionException(
"Application finished with exit code: " + exitCode);
}
catch (Exception ex) {
throw new MojoExecutionException("Could not exec java", ex);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment