From b5093684c1c999b19a1d1fda097feb2fb0d4b1f7 Mon Sep 17 00:00:00 2001 From: "pixeebot[bot]" <104101892+pixeebot[bot]@users.noreply.github.com> Date: Thu, 18 Apr 2024 08:43:35 +0000 Subject: [PATCH] Prevent file descriptor leak and modernize BufferedWriter creation --- .../internal/conventions/precommit/LicenseHeadersTask.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build-conventions/src/main/java/org/elasticsearch/gradle/internal/conventions/precommit/LicenseHeadersTask.java b/build-conventions/src/main/java/org/elasticsearch/gradle/internal/conventions/precommit/LicenseHeadersTask.java index 76b117f8f5308..b2bb3af1028d9 100644 --- a/build-conventions/src/main/java/org/elasticsearch/gradle/internal/conventions/precommit/LicenseHeadersTask.java +++ b/build-conventions/src/main/java/org/elasticsearch/gradle/internal/conventions/precommit/LicenseHeadersTask.java @@ -207,7 +207,7 @@ private IHeaderMatcher subStringMatcher(String licenseFamilyCategory, String lic private ClaimStatistic generateReport(ReportConfiguration config, File xmlReportFile) { try { Files.deleteIfExists(reportFile.get().getAsFile().toPath()); - BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(xmlReportFile)); + BufferedWriter bufferedWriter = Files.newBufferedWriter(xmlReportFile.toPath()); return toXmlReportFile(config, bufferedWriter); } catch (IOException | RatException exception) { throw new GradleException("Cannot generate license header report for " + getPath(), exception);