diff --git a/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/RunProcess.java b/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/RunProcess.java index e8873abf650..ea2819732b3 100644 --- a/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/RunProcess.java +++ b/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/RunProcess.java @@ -76,6 +76,9 @@ public class RunProcess { } private boolean inheritIO(ProcessBuilder builder) { + if (isInheritIOBroken()) { + return false; + } try { INHERIT_IO_METHOD.invoke(builder); return true; @@ -85,6 +88,32 @@ public class RunProcess { } } + // There's a bug in the Windows VM (https://bugs.openjdk.java.net/browse/JDK-8023130) + // that means we need to avoid inheritIO + private static boolean isInheritIOBroken() { + if (!System.getProperty("os.name", "none").toLowerCase().contains("windows")) { + return false; + } + String runtime = System.getProperty("java.runtime.version"); + if (!runtime.startsWith("1.7")) { + return false; + } + String[] tokens = runtime.split("_"); + if (tokens.length < 2) { + return true; // No idea actually, shouldn't happen + } + try { + Integer build = Integer.valueOf(tokens[1].split("[^0-9]")[0]); + if (build < 60) { + return true; + } + } + catch (Exception e) { + return true; + } + return false; + } + private void redirectOutput(Process process) { final BufferedReader reader = new BufferedReader(new InputStreamReader( process.getInputStream())); @@ -96,6 +125,7 @@ public class RunProcess { while (line != null) { System.out.println(line); line = reader.readLine(); + System.out.flush(); } reader.close(); } 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 27671ec9404..e29af53da4f 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 @@ -160,8 +160,9 @@ public class RunMojo extends AbstractMojo { StringBuilder classpath = new StringBuilder(); for (URL ele : getClassPathUrls()) { classpath = classpath.append((classpath.length() > 0 ? File.pathSeparator - : "") + ele); + : "") + new File(ele.toURI())); } + getLog().debug("Classpath for forked process: " + classpath); args.add("-cp"); args.add(classpath.toString()); }