From b3e0b3a54222bfa4a8dfcd1f925c1c6ee921b892 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Mon, 15 Aug 2016 11:23:26 +0100 Subject: [PATCH] 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 --- .../java/org/springframework/boot/maven/RunMojo.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/RunMojo.java b/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/RunMojo.java index 0d38fa5c898..28f2c348e66 100644 --- a/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/RunMojo.java +++ b/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/RunMojo.java @@ -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 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);