This is an automated email from the ASF dual-hosted git repository. elharo pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/maven.git
The following commit(s) were added to refs/heads/master by this push: new dacb81a4d1 use try-with-resources statement in LookupWagonMojo (#2426) dacb81a4d1 is described below commit dacb81a4d18c7ed91bbcfaa890a6bda00f3b5e39 Author: Pankraz76 <8830888+pankra...@users.noreply.github.com> AuthorDate: Thu Jun 5 12:25:33 2025 +0200 use try-with-resources statement in LookupWagonMojo (#2426) Co-authored-by: Vincent Potucek <vpotu...@me.com> --- .../org/apache/maven/plugin/coreit/LookupWagonMojo.java | 16 +++------------- 1 file changed, 3 insertions(+), 13 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 278868010a..93d0bf9527 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,21 +92,11 @@ public void execute() throws MojoExecutionException, MojoFailureException { getLog().info("[MAVEN-CORE-IT-LOG] Creating output file " + outputFile); - OutputStream out = null; - try { - outputFile.getParentFile().mkdirs(); - out = new FileOutputStream(outputFile); + outputFile.getParentFile().mkdirs(); + try (OutputStream out = new FileOutputStream(outputFile)) { loaderProperties.store(out, "MAVEN-CORE-IT-LOG"); } catch (IOException e) { - throw new MojoExecutionException("Output file could not be created: " + outputFile, e); - } finally { - if (out != null) { - try { - out.close(); - } catch (IOException e) { - // just ignore - } - } + throw new MojoExecutionException(e); } getLog().info("[MAVEN-CORE-IT-LOG] Created output file " + outputFile);