From d7c7e10634902394df51f2238cc215826bc22230 Mon Sep 17 00:00:00 2001 From: Pankraz76 <8830888+Pankraz76@users.noreply.github.com> Date: Wed, 11 Jun 2025 08:19:06 +0200 Subject: [PATCH] Revert "use try-with-resources statement in LookupWagonMojo (#2426)" This reverts commit dacb81a4d18c7ed91bbcfaa890a6bda00f3b5e39. --- .../maven/plugin/coreit/LookupWagonMojo.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/its/core-it-support/core-it-plugins/maven-it-plugin-uses-wagon/src/main/java/org/apache/maven/plugin/coreit/LookupWagonMojo.java b/its/core-it-support/core-it-plugins/maven-it-plugin-uses-wagon/src/main/java/org/apache/maven/plugin/coreit/LookupWagonMojo.java index 93d0bf9527b6..278868010a17 100644 --- a/its/core-it-support/core-it-plugins/maven-it-plugin-uses-wagon/src/main/java/org/apache/maven/plugin/coreit/LookupWagonMojo.java +++ b/its/core-it-support/core-it-plugins/maven-it-plugin-uses-wagon/src/main/java/org/apache/maven/plugin/coreit/LookupWagonMojo.java @@ -92,11 +92,21 @@ public void execute() throws MojoExecutionException, MojoFailureException { getLog().info("[MAVEN-CORE-IT-LOG] Creating output file " + outputFile); - outputFile.getParentFile().mkdirs(); - try (OutputStream out = new FileOutputStream(outputFile)) { + OutputStream out = null; + try { + outputFile.getParentFile().mkdirs(); + out = new FileOutputStream(outputFile); loaderProperties.store(out, "MAVEN-CORE-IT-LOG"); } catch (IOException e) { - throw new MojoExecutionException(e); + throw new MojoExecutionException("Output file could not be created: " + outputFile, e); + } finally { + if (out != null) { + try { + out.close(); + } catch (IOException e) { + // just ignore + } + } } getLog().info("[MAVEN-CORE-IT-LOG] Created output file " + outputFile);