Skip to content

Commit 62978e4

Browse files
author
Marcelo Vanzin
committed
Minor cleanup of Windows code path.
1 parent 9cd5b44 commit 62978e4

File tree

1 file changed

+5
-11
lines changed
  • launcher/src/main/java/org/apache/spark/launcher

1 file changed

+5
-11
lines changed

launcher/src/main/java/org/apache/spark/launcher/Main.java

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,7 @@ public static void main(String[] argsArray) throws Exception {
7575
}
7676

7777
if (isWindows()) {
78-
List<String> winCmd = prepareForWindows(cmd, env);
79-
System.out.println(join(" ", cmd));
78+
System.out.println(prepareForWindows(cmd, env));
8079
} else {
8180
List<String> bashCmd = prepareForBash(cmd, env);
8281
for (String c : bashCmd) {
@@ -101,23 +100,18 @@ public static void main(String[] argsArray) throws Exception {
101100
* The command is executed using "cmd /c" and formatted as single line, since that's the
102101
* easiest way to consume this from a batch script (see spark-class2.cmd).
103102
*/
104-
private static List<String> prepareForWindows(List<String> cmd, Map<String, String> childEnv) {
103+
private static String prepareForWindows(List<String> cmd, Map<String, String> childEnv) {
105104
StringBuilder cmdline = new StringBuilder("cmd /c \"");
106105
for (Map.Entry<String, String> e : childEnv.entrySet()) {
107-
if (cmdline.length() > 0) {
108-
cmdline.append(" ");
109-
}
110106
cmdline.append(String.format("set %s=%s", e.getKey(), e.getValue()));
111-
cmdline.append(" &&");
107+
cmdline.append(" && ");
112108
}
113109
for (String arg : cmd) {
114-
if (cmdline.length() > 0) {
115-
cmdline.append(" ");
116-
}
117110
cmdline.append(quoteForBatchScript(arg));
111+
cmdline.append(" ");
118112
}
119113
cmdline.append("\"");
120-
return Arrays.asList(cmdline.toString());
114+
return cmdline.toString();
121115
}
122116

123117
/**

0 commit comments

Comments
 (0)