From b236076f88b86b4f88a8fd4b6b5d20b8a6711686 Mon Sep 17 00:00:00 2001 From: Ryan Ernst Date: Wed, 27 Nov 2019 16:16:56 -0800 Subject: [PATCH] Fix java 8 compile for Files.readString usage --- .../java/org/elasticsearch/packaging/util/ServerUtils.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/qa/os/src/test/java/org/elasticsearch/packaging/util/ServerUtils.java b/qa/os/src/test/java/org/elasticsearch/packaging/util/ServerUtils.java index 62f9cee137b..34a46b908d5 100644 --- a/qa/os/src/test/java/org/elasticsearch/packaging/util/ServerUtils.java +++ b/qa/os/src/test/java/org/elasticsearch/packaging/util/ServerUtils.java @@ -36,6 +36,7 @@ import java.nio.file.Files; import java.nio.file.Path; import java.util.Objects; import java.util.concurrent.TimeUnit; +import java.util.stream.Stream; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.containsString; @@ -58,8 +59,9 @@ public class ServerUtils { if (installation.distribution.packaging != Distribution.Packaging.DOCKER) { Path configFilePath = installation.config("elasticsearch.yml"); // this is fragile, but currently doesn't deviate from a single line enablement and not worth the parsing effort - String configFile = Files.readString(configFilePath, StandardCharsets.UTF_8); - securityEnabled = configFile.contains(SECURITY_ENABLED); + try (Stream lines = Files.lines(configFilePath, StandardCharsets.UTF_8)) { + securityEnabled = lines.anyMatch(line -> line.contains(SECURITY_ENABLED)); + } } if (securityEnabled) {