diff --git a/java-client/src/test/java/co/elastic/clients/elasticsearch/ElasticsearchTestServer.java b/java-client/src/test/java/co/elastic/clients/elasticsearch/ElasticsearchTestServer.java index 03990faae..9da83f8ba 100644 --- a/java-client/src/test/java/co/elastic/clients/elasticsearch/ElasticsearchTestServer.java +++ b/java-client/src/test/java/co/elastic/clients/elasticsearch/ElasticsearchTestServer.java @@ -63,6 +63,7 @@ public class ElasticsearchTestServer implements AutoCloseable { private ElasticsearchClient client; private static ElasticsearchTestServer global; + private static final String artifactsApiUrl = "https://artifacts-api.elastic.co/v1/versions/"; public static synchronized ElasticsearchTestServer global() { if (global == null) { @@ -131,11 +132,8 @@ private Version selectLatestVersion(Version version, String info) { } private String fetchAndWriteVersionInfo(File file) throws IOException { - String versionInfo = IOUtils.toString(new URL("https://artifacts-api.elastic" + - ".co/v1/versions/"), StandardCharsets.UTF_8); - try (FileWriter fw = new FileWriter(file, false)) { - fw.write(versionInfo); - } + String versionInfo = IOUtils.toString(new URL(artifactsApiUrl), StandardCharsets.UTF_8); + FileUtils.writeStringToFile(file, versionInfo, StandardCharsets.UTF_8); return versionInfo; }