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) {