Skip to content

Commit

Permalink
using io utils also for writing
Browse files Browse the repository at this point in the history
  • Loading branch information
l-trotta committed Nov 14, 2024
1 parent 6d037ac commit 3f0d1f1
Showing 1 changed file with 3 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit 3f0d1f1

Please sign in to comment.