Fix compilation in JVM options parser code

Compilation was accidentally broken here when a backport used code from
JDK 9, which is not supported in 7.x. This commit addresses this by
using JDK 8 compatiable APIs.
This commit is contained in:
Jason Tedor 2019-10-04 19:29:20 -04:00
parent 8a7e5b0847
commit 43f588a29e
No known key found for this signature in database
GPG Key ID: 8CF9C19984731E85
2 changed files with 5 additions and 3 deletions

View File

@ -31,6 +31,7 @@ import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
@ -87,7 +88,7 @@ final class JvmOptionsParser {
.collect(Collectors.toList()));
}
final List<String> substitutedJvmOptions =
substitutePlaceholders(jvmOptions, Map.of("ES_TMPDIR", System.getenv("ES_TMPDIR")));
substitutePlaceholders(jvmOptions, Collections.singletonMap("ES_TMPDIR", System.getenv("ES_TMPDIR")));
final List<String> ergonomicJvmOptions = JvmErgonomics.choose(substitutedJvmOptions);
substitutedJvmOptions.addAll(ergonomicJvmOptions);
final String spaceDelimitedJvmOptions = spaceDelimitJvmOptions(substitutedJvmOptions);

View File

@ -41,8 +41,9 @@ import static org.junit.Assert.fail;
public class JvmOptionsParserTests extends LaunchersTestCase {
public void testSubstitution() {
final List<String> jvmOptions =
JvmOptionsParser.substitutePlaceholders(List.of("-Djava.io.tmpdir=${ES_TMPDIR}"), Map.of("ES_TMPDIR", "/tmp/elasticsearch"));
final List<String> jvmOptions = JvmOptionsParser.substitutePlaceholders(
Collections.singletonList("-Djava.io.tmpdir=${ES_TMPDIR}"),
Collections.singletonMap("ES_TMPDIR", "/tmp/elasticsearch"));
assertThat(jvmOptions, contains("-Djava.io.tmpdir=/tmp/elasticsearch"));
}