Skip to content

Commit dacb81a

Browse files
Pankraz76Vincent Potucek
andauthored
use try-with-resources statement in LookupWagonMojo (#2426)
Co-authored-by: Vincent Potucek <[email protected]>
1 parent 28458ba commit dacb81a

File tree

1 file changed

+3
-13
lines changed
  • its/core-it-support/core-it-plugins/maven-it-plugin-uses-wagon/src/main/java/org/apache/maven/plugin/coreit

1 file changed

+3
-13
lines changed

its/core-it-support/core-it-plugins/maven-it-plugin-uses-wagon/src/main/java/org/apache/maven/plugin/coreit/LookupWagonMojo.java

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -92,21 +92,11 @@ public void execute() throws MojoExecutionException, MojoFailureException {
9292

9393
getLog().info("[MAVEN-CORE-IT-LOG] Creating output file " + outputFile);
9494

95-
OutputStream out = null;
96-
try {
97-
outputFile.getParentFile().mkdirs();
98-
out = new FileOutputStream(outputFile);
95+
outputFile.getParentFile().mkdirs();
96+
try (OutputStream out = new FileOutputStream(outputFile)) {
9997
loaderProperties.store(out, "MAVEN-CORE-IT-LOG");
10098
} catch (IOException e) {
101-
throw new MojoExecutionException("Output file could not be created: " + outputFile, e);
102-
} finally {
103-
if (out != null) {
104-
try {
105-
out.close();
106-
} catch (IOException e) {
107-
// just ignore
108-
}
109-
}
99+
throw new MojoExecutionException(e);
110100
}
111101

112102
getLog().info("[MAVEN-CORE-IT-LOG] Created output file " + outputFile);

0 commit comments

Comments
 (0)