From 3f0d1f1880c70242708f7fde1cf9e988c5e91162 Mon Sep 17 00:00:00 2001 From: Laura Trotta Date: Thu, 14 Nov 2024 16:51:15 +0100 Subject: [PATCH] using io utils also for writing --- .../clients/elasticsearch/ElasticsearchTestServer.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) 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; }