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

Gary Gregory edited comment on IO-502 at 4/25/16 10:00 PM:
-----------------------------------------------------------

In this part of the patch:

{code:java}
Index: src/main/java/org/apache/commons/io/FileUtils.java
===================================================================
--- src/main/java/org/apache/commons/io/FileUtils.java  (Revision 1740841)
+++ src/main/java/org/apache/commons/io/FileUtils.java  (Arbeitskopie)
@@ -1154,6 +1154,18 @@
                 }
                 pos += bytesCopied;
             }
+
+            output.close();
+            output = null;
+
+            fos.close();
+            fos = null;
+
+            input.close();
+            input = null;
+
+            fis.close();
+            fis = null;
         } finally {
             IOUtils.closeQuietly(output, fos, input, fis);
         }
{code}

... some exceptions are still dropped on the floor. For example, output.close() 
works but fos.close() fails, then you do not "see" other failures. So what we 
really trying to do here, hide all except the 1st failure? But then, what is 
the proper order all the of close() calls. Should other errors then at least be 
printed on the console? Yikes. Sounds like a mess!

A change like this could also trip up existing apps in the case where 
exceptions are now thrown. But it seems quite legitimate to me... I would not 
care that the input fails to close but I sure do care about the output. 

Perhaps, always throwing an exception on closing the output and ignoring 
exceptions on closing the input would be best?

Thoughts?


was (Author: garydgregory):
In this part of the patch:

{code:java}

> Exceptions are suppressed incorrectly when copying files.
> ---------------------------------------------------------
>
>                 Key: IO-502
>                 URL: https://issues.apache.org/jira/browse/IO-502
>             Project: Commons IO
>          Issue Type: Bug
>          Components: Utilities
>            Reporter: Christian Schulte
>            Priority: Critical
>         Attachments: IO-502.patch
>
>
> When copying files or directories, exceptions thrown on closing streams are 
> suppressed incorrectly and need to be propagated to the caller.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to