Skip to content

Commit f3d2264

Browse files
author
Vincent Potucek
committed
use try-with-resources statement in CheckThreadSafetyMojo
1 parent 28458ba commit f3d2264

1 file changed

Lines changed: 3 additions & 13 deletions

File tree

  • its/core-it-support/core-it-plugins/maven-it-plugin-active-collection/src/main/java/org/apache/maven/plugin/coreit

its/core-it-support/core-it-plugins/maven-it-plugin-active-collection/src/main/java/org/apache/maven/plugin/coreit/CheckThreadSafetyMojo.java

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -133,21 +133,11 @@ public void run() {
133133

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

136-
OutputStream out = null;
137-
try {
138-
outputFile.getParentFile().mkdirs();
139-
out = new FileOutputStream(outputFile);
136+
outputFile.getParentFile().mkdirs();
137+
try (OutputStream out = new FileOutputStream(outputFile)){
140138
componentProperties.store(out, "MAVEN-CORE-IT-LOG");
141139
} catch (IOException e) {
142-
throw new MojoExecutionException("Output file could not be created: " + outputFile, e);
143-
} finally {
144-
if (out != null) {
145-
try {
146-
out.close();
147-
} catch (IOException e) {
148-
// just ignore
149-
}
150-
}
140+
throw new MojoExecutionException(e);
151141
}
152142

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

0 commit comments

Comments
 (0)