Fix java 8 compile for Files.readString usage
This commit is contained in:
parent
7802b60a5a
commit
b236076f88
|
@ -36,6 +36,7 @@ import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import static org.hamcrest.MatcherAssert.assertThat;
|
import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
import static org.hamcrest.Matchers.containsString;
|
import static org.hamcrest.Matchers.containsString;
|
||||||
|
@ -58,8 +59,9 @@ public class ServerUtils {
|
||||||
if (installation.distribution.packaging != Distribution.Packaging.DOCKER) {
|
if (installation.distribution.packaging != Distribution.Packaging.DOCKER) {
|
||||||
Path configFilePath = installation.config("elasticsearch.yml");
|
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
|
// 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);
|
try (Stream<String> lines = Files.lines(configFilePath, StandardCharsets.UTF_8)) {
|
||||||
securityEnabled = configFile.contains(SECURITY_ENABLED);
|
securityEnabled = lines.anyMatch(line -> line.contains(SECURITY_ENABLED));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (securityEnabled) {
|
if (securityEnabled) {
|
||||||
|
|
Loading…
Reference in New Issue