[ 
https://issues.apache.org/jira/browse/RAT-109?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13160090#comment-13160090
 ] 

John Vines commented on RAT-109:
--------------------------------

This patch does not work, at least for my project. It fails because mkdirs does 
not create the directories, but it does not create the directories because it 
already exists. It should only throw that exception if the folder does not 
exist and it fails to create. Patch is pasted below (I tested it for my case at 
the very least).

Index: src/main/java/org/apache/rat/mp/RatCheckMojo.java
===================================================================
--- src/main/java/org/apache/rat/mp/RatCheckMojo.java   (revision 1208465)
+++ src/main/java/org/apache/rat/mp/RatCheckMojo.java   (working copy)
@@ -153,7 +153,7 @@
     public void execute() throws MojoExecutionException, MojoFailureException
     {
         File parent = reportFile.getParentFile();
-        if(!parent.mkdirs()) {
+        if (!parent.exists() && !parent.mkdirs()) {
             throw new MojoExecutionException("Could not create report parent 
directory " + parent);
         }
 

                
> Return value of mkdirs() is not checked and no error handling occurs
> --------------------------------------------------------------------
>
>                 Key: RAT-109
>                 URL: https://issues.apache.org/jira/browse/RAT-109
>             Project: RAT
>          Issue Type: Bug
>    Affects Versions: 0.9
>         Environment: Revision: 1208077
>            Reporter: Hugo Hirsch
>             Fix For: 0.9
>
>         Attachments: RAT109checkmkdirsReturnValue.patch
>
>
> The code contains calls to mkdir() without checking its return value.
> Patch attached for classes:
> *       apache-rat-plugin/src/main/java/org/apache/rat/mp/RatReportMojo.java
> *       apache-rat-plugin/src/main/java/org/apache/rat/mp/RatCheckMojo.java
> *       apache-rat-tasks/src/test/java/org/apache/rat/anttasks/ReportTest.java

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to