From f3d312698f784d5dfaac42a4129e40c9c6c83327 Mon Sep 17 00:00:00 2001 From: Joakim Erdfelt Date: Thu, 27 Mar 2014 12:36:34 -0700 Subject: [PATCH] 425736 - jetty-start / Jetty 9 fails to startup with --exec option if Java path contain + Using .addRawArg() to avoid space escaping for Java Bin --- .../eclipse/jetty/start/CommandLineBuilder.java | 15 +++++++++++++++ .../main/java/org/eclipse/jetty/start/Main.java | 1 + .../java/org/eclipse/jetty/start/StartArgs.java | 8 ++++---- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/jetty-start/src/main/java/org/eclipse/jetty/start/CommandLineBuilder.java b/jetty-start/src/main/java/org/eclipse/jetty/start/CommandLineBuilder.java index ccf127e0028..8f4fd8c4c92 100644 --- a/jetty-start/src/main/java/org/eclipse/jetty/start/CommandLineBuilder.java +++ b/jetty-start/src/main/java/org/eclipse/jetty/start/CommandLineBuilder.java @@ -192,4 +192,19 @@ public class CommandLineBuilder return buf.toString(); } + + public void debug() + { + if (!StartLog.isDebugEnabled()) + { + return; + } + + int len = args.size(); + StartLog.debug("Command Line: %,d entries",args.size()); + for (int i = 0; i < len; i++) + { + StartLog.debug(" [%d]: \"%s\"",i,args.get(i)); + } + } } diff --git a/jetty-start/src/main/java/org/eclipse/jetty/start/Main.java b/jetty-start/src/main/java/org/eclipse/jetty/start/Main.java index 986eb324718..12d64643804 100644 --- a/jetty-start/src/main/java/org/eclipse/jetty/start/Main.java +++ b/jetty-start/src/main/java/org/eclipse/jetty/start/Main.java @@ -687,6 +687,7 @@ public class Main if (args.isExec()) { CommandLineBuilder cmd = args.getMainArgs(baseHome,true); + cmd.debug(); ProcessBuilder pbuilder = new ProcessBuilder(cmd.getArgs()); final Process process = pbuilder.start(); Runtime.getRuntime().addShutdownHook(new Thread() diff --git a/jetty-start/src/main/java/org/eclipse/jetty/start/StartArgs.java b/jetty-start/src/main/java/org/eclipse/jetty/start/StartArgs.java index def8e1a5009..49f4e95a5e5 100644 --- a/jetty-start/src/main/java/org/eclipse/jetty/start/StartArgs.java +++ b/jetty-start/src/main/java/org/eclipse/jetty/start/StartArgs.java @@ -408,11 +408,11 @@ public class StartArgs if (addJavaInit) { - cmd.addArg(CommandLineBuilder.findJavaBin()); + cmd.addRawArg(CommandLineBuilder.findJavaBin()); for (String x : jvmArgs) { - cmd.addArg(x); + cmd.addRawArg(x); } cmd.addRawArg("-Djetty.home=" + baseHome.getHome()); @@ -425,7 +425,7 @@ public class StartArgs cmd.addEqualsArg("-D" + propKey,value); } - cmd.addArg("-cp"); + cmd.addRawArg("-cp"); cmd.addRawArg(classpath.toString()); cmd.addRawArg(getMainClassname()); } @@ -447,7 +447,7 @@ public class StartArgs { properties.store(out,"start.jar properties"); } - cmd.addArg(prop_file.getAbsolutePath()); + cmd.addRawArg(prop_file.getAbsolutePath()); } for (File xml : xmls)