Pankraz76 commented on code in PR #2396:
URL: https://github.com/apache/maven/pull/2396#discussion_r2109728748


##########
its/core-it-suite/src/test/resources/mng-2135/plugin/src/main/java/coreit/ItMojo.java:
##########
@@ -52,8 +52,8 @@ public class ItMojo extends AbstractMojo {
     private File outputFile;
 
     public void execute() throws MojoExecutionException {
+        outputFile.getParentFile().mkdirs();

Review Comment:
   
   The code should look like this, but `mkdir` failing is very rare and not 
part of the happy path. Since this step is used for the subsequent 
try-with-resources block, it would naturally result in the same `IOError` 
anyway—without requiring an explicit check—while also preventing an attempt to 
read a resource that couldn’t be created in the first place. This is the 
logical approach, though it wasn’t handled before either.  
   
   Currently, there’s no explicit code handling this state. We *could* add 
preemptive checks, of course. Writing the missing `if` statements—which is what 
I’d normally expect—would change the code slightly more, as it introduces 
validation for three previously unchecked outcomes.  
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@maven.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to