diff --git a/distribution/tools/launchers/src/main/java/org/elasticsearch/tools/launchers/JvmOptionsParser.java b/distribution/tools/launchers/src/main/java/org/elasticsearch/tools/launchers/JvmOptionsParser.java index 936d4f51b8309..dcb14dd949472 100644 --- a/distribution/tools/launchers/src/main/java/org/elasticsearch/tools/launchers/JvmOptionsParser.java +++ b/distribution/tools/launchers/src/main/java/org/elasticsearch/tools/launchers/JvmOptionsParser.java @@ -35,7 +35,6 @@ import java.util.Arrays; import java.util.Collections; import java.util.HashMap; -import java.util.Iterator; import java.util.List; import java.util.Locale; import java.util.Map; @@ -95,8 +94,7 @@ public static void main(final String[] args) throws InterruptedException, IOExce try { final List jvmOptions = parser.jvmOptions(Paths.get(args[0]), System.getenv("ES_JAVA_OPTS"), substitutions); - final String spaceDelimitedJvmOptions = spaceDelimitJvmOptions(jvmOptions); - Launchers.outPrintln(spaceDelimitedJvmOptions); + Launchers.outPrintln(String.join(" ", jvmOptions)); } catch (final JvmOptionsFileParserException e) { final String errorMessage = String.format( Locale.ROOT, @@ -340,22 +338,4 @@ static void parse( } } - /** - * Delimits the specified JVM options by spaces. - * - * @param jvmOptions the JVM options - * @return a single-line string containing the specified JVM options in the order they appear delimited by spaces - */ - static String spaceDelimitJvmOptions(final List jvmOptions) { - final StringBuilder spaceDelimitedJvmOptionsBuilder = new StringBuilder(); - final Iterator it = jvmOptions.iterator(); - while (it.hasNext()) { - spaceDelimitedJvmOptionsBuilder.append(it.next()); - if (it.hasNext()) { - spaceDelimitedJvmOptionsBuilder.append(" "); - } - } - return spaceDelimitedJvmOptionsBuilder.toString(); - } - } diff --git a/distribution/tools/launchers/src/test/java/org/elasticsearch/tools/launchers/JvmOptionsParserTests.java b/distribution/tools/launchers/src/test/java/org/elasticsearch/tools/launchers/JvmOptionsParserTests.java index 57e63fde8b87f..953328b13c493 100644 --- a/distribution/tools/launchers/src/test/java/org/elasticsearch/tools/launchers/JvmOptionsParserTests.java +++ b/distribution/tools/launchers/src/test/java/org/elasticsearch/tools/launchers/JvmOptionsParserTests.java @@ -246,13 +246,4 @@ public void accept(final int lineNumber, final String line) { assertThat(seenInvalidLines, equalTo(invalidLines)); } - public void testSpaceDelimitedJvmOptions() { - assertThat(JvmOptionsParser.spaceDelimitJvmOptions(Collections.singletonList("-Xms1g")), equalTo("-Xms1g")); - assertThat(JvmOptionsParser.spaceDelimitJvmOptions(Arrays.asList("-Xms1g", "-Xmx1g")), equalTo("-Xms1g -Xmx1g")); - assertThat( - JvmOptionsParser.spaceDelimitJvmOptions(Arrays.asList("-Xms1g", "-Xmx1g", "-XX:+UseG1GC")), - equalTo("-Xms1g -Xmx1g -XX:+UseG1GC") - ); - } - }