Skip to content

Commit f058c50

Browse files
author
Vincent Potucek
committed
try can use automatic resource management
1 parent a96e660 commit f058c50

File tree

2 files changed

+2
-12
lines changed
  • its/core-it-support/core-it-plugins
    • maven-it-plugin-class-loader/maven-it-plugin-class-loader/src/main/java/org/apache/maven/plugin/coreit
    • maven-it-plugin-configuration/src/main/java/org/apache/maven/plugin/coreit

2 files changed

+2
-12
lines changed

its/core-it-support/core-it-plugins/maven-it-plugin-class-loader/maven-it-plugin-class-loader/src/main/java/org/apache/maven/plugin/coreit/PropertiesUtil.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
package org.apache.maven.plugin.coreit;
2020

2121
import java.io.File;
22-
import java.io.FileOutputStream;
2322
import java.io.IOException;
2423
import java.io.OutputStream;
2524
import java.nio.file.Files;

its/core-it-support/core-it-plugins/maven-it-plugin-configuration/src/main/java/org/apache/maven/plugin/coreit/PropertiesUtil.java

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -69,21 +69,12 @@ public static Properties read(File inputFile) throws MojoExecutionException {
6969
}
7070

7171
public static void write(File outputFile, Properties props) throws MojoExecutionException {
72-
OutputStream os = null;
73-
createOutputFile(outputFile);
74-
try {
75-
os = new FileOutputStream(outputFile);
72+
outputFile.getParentFile().mkdirs();
73+
try (OutputStream os = new FileOutputStream(outputFile)) {
7674
props.store(os, "MAVEN-CORE-IT-LOG");
7775
} catch (IOException e) {
7876
throw new MojoExecutionException(
7977
"Output file " + outputFile + " could not be created: " + e.getMessage(), e);
80-
} finally {
81-
if (os != null) {
82-
try {
83-
os.close();
84-
} catch (IOException ignore) {
85-
}
86-
}
8778
}
8879
}
8980

0 commit comments

Comments
 (0)