Skip to content

Commit 469a8e6

Browse files
author
Vincent Potucek
committed
avoid false IO catch on mkdirs()
1 parent d3f8281 commit 469a8e6

File tree

33 files changed

+33
-36
lines changed

33 files changed

+33
-36
lines changed

its/core-it-suite/src/test/resources/mng-2135/plugin/src/main/java/coreit/ItMojo.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ public class ItMojo extends AbstractMojo {
5252
private File outputFile;
5353

5454
public void execute() throws MojoExecutionException {
55+
outputFile.getParentFile().mkdirs();
5556
try {
56-
outputFile.getParentFile().mkdirs();
5757
outputFile.createNewFile();
5858
} catch (IOException e) {
5959
throw new MojoExecutionException("Failed to create touch file: " + e.getMessage(), e);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,8 @@ public void execute() throws MojoExecutionException, MojoFailureException {
118118
getLog().info("[MAVEN-CORE-IT-LOG] Creating output file " + outputFile);
119119

120120
OutputStream out = null;
121+
outputFile.getParentFile().mkdirs();
121122
try {
122-
outputFile.getParentFile().mkdirs();
123123
out = new FileOutputStream(outputFile);
124124
componentProperties.store(out, "MAVEN-CORE-IT-LOG");
125125
} catch (IOException e) {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,8 @@ public void run() {
134134
getLog().info("[MAVEN-CORE-IT-LOG] Creating output file " + outputFile);
135135

136136
OutputStream out = null;
137+
outputFile.getParentFile().mkdirs();
137138
try {
138-
outputFile.getParentFile().mkdirs();
139139
out = new FileOutputStream(outputFile);
140140
componentProperties.store(out, "MAVEN-CORE-IT-LOG");
141141
} catch (IOException e) {

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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ class PropertiesUtil {
3636

3737
public static void write(File outputFile, Properties props) throws MojoExecutionException {
3838
OutputStream out = null;
39+
outputFile.getParentFile().mkdirs();
3940
try {
40-
outputFile.getParentFile().mkdirs();
4141
out = new FileOutputStream(outputFile);
4242
props.store(out, "MAVEN-CORE-IT-LOG");
4343
} catch (IOException e) {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ public static Properties read(File inputFile) throws MojoExecutionException {
7070

7171
public static void write(File outputFile, Properties props) throws MojoExecutionException {
7272
OutputStream os = null;
73+
outputFile.getParentFile().mkdirs();
7374
try {
74-
outputFile.getParentFile().mkdirs();
7575
os = new FileOutputStream(outputFile);
7676
props.store(os, "MAVEN-CORE-IT-LOG");
7777
} catch (IOException e) {

its/core-it-support/core-it-plugins/maven-it-plugin-core-stubs/maven-clean-plugin/src/main/java/org/apache/maven/plugin/coreit/CleanMojo.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,9 @@ public void execute() throws MojoExecutionException, MojoFailureException {
7070
outputFile = new File(project.getBasedir(), pathname).getAbsoluteFile();
7171
}
7272

73-
getLog().info("[MAVEN-CORE-IT-LOG] Creating output file: " + outputFile);
7473

74+
outputFile.getParentFile().mkdirs();
7575
try {
76-
outputFile.getParentFile().mkdirs();
7776
outputFile.createNewFile();
7877
} catch (IOException e) {
7978
throw new MojoExecutionException("Output file could not be created: " + pathname, e);

its/core-it-support/core-it-plugins/maven-it-plugin-core-stubs/maven-compiler-plugin/src/main/java/org/apache/maven/plugin/coreit/CompileMojo.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,9 @@ public void execute() throws MojoExecutionException, MojoFailureException {
7070
outputFile = new File(project.getBasedir(), pathname).getAbsoluteFile();
7171
}
7272

73-
getLog().info("[MAVEN-CORE-IT-LOG] Creating output file: " + outputFile);
7473

74+
outputFile.getParentFile().mkdirs();
7575
try {
76-
outputFile.getParentFile().mkdirs();
7776
outputFile.createNewFile();
7877
} catch (IOException e) {
7978
throw new MojoExecutionException("Output file could not be created: " + pathname, e);

its/core-it-support/core-it-plugins/maven-it-plugin-core-stubs/maven-compiler-plugin/src/main/java/org/apache/maven/plugin/coreit/TestCompileMojo.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,9 @@ public void execute() throws MojoExecutionException, MojoFailureException {
7070
outputFile = new File(project.getBasedir(), pathname).getAbsoluteFile();
7171
}
7272

73-
getLog().info("[MAVEN-CORE-IT-LOG] Creating output file: " + outputFile);
7473

74+
outputFile.getParentFile().mkdirs();
7575
try {
76-
outputFile.getParentFile().mkdirs();
7776
outputFile.createNewFile();
7877
} catch (IOException e) {
7978
throw new MojoExecutionException("Output file could not be created: " + pathname, e);

its/core-it-support/core-it-plugins/maven-it-plugin-core-stubs/maven-deploy-plugin/src/main/java/org/apache/maven/plugin/coreit/DeployMojo.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ public void execute() throws MojoExecutionException, MojoFailureException {
7272

7373
getLog().info("[MAVEN-CORE-IT-LOG] Creating output file: " + outputFile);
7474

75+
outputFile.getParentFile().mkdirs();
7576
try {
76-
outputFile.getParentFile().mkdirs();
7777
outputFile.createNewFile();
7878
} catch (IOException e) {
7979
throw new MojoExecutionException("Output file could not be created: " + pathname, e);

its/core-it-support/core-it-plugins/maven-it-plugin-core-stubs/maven-ear-plugin/src/main/java/org/apache/maven/plugin/coreit/EarMojo.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ public void execute() throws MojoExecutionException, MojoFailureException {
7272

7373
getLog().info("[MAVEN-CORE-IT-LOG] Creating output file: " + outputFile);
7474

75+
outputFile.getParentFile().mkdirs();
7576
try {
76-
outputFile.getParentFile().mkdirs();
7777
outputFile.createNewFile();
7878
} catch (IOException e) {
7979
throw new MojoExecutionException("Output file could not be created: " + pathname, e);

0 commit comments

Comments
 (0)