commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Stephen Colebourne" <stephencolebou...@hotmail.com>
Subject Re: [io] copyAndClose
Date Tue, 08 Feb 2005 00:37:23 GMT
From: "B. K. Oxley (binkley)" <binkley@alumni.rice.edu>
> I do not understand.  What is being copied in the finally block?  Should 
> that have been:
>
>     finally {
>         IOUtils.closeQuietly(in);
>         IOUtils.closeQuietly(out);
>     }
Oops ;-) Yes

> I do not want to swallow exceptions thrown by closing in or out as they 
> might indicate to the caller some kind of important failure (say a network 
> error).  That is why my original has nexted try/finally blocks:
>
>     finally {
>         try {
>             out.close();
>         } finally {
>             in.close();
>         }
>     }
Oh. This is quite dangerous code as if both the closing of out and in throw 
an exception only the exception from in is actually thrown.

The question then becomes whether the method to add to IOUtils is 
copyAndClose() or copyAndCloseQuietly()

I wonder if any other committer has a view.

>> Were you interested in writing the patch and tests for IOUtils?
>
> Do I just pull IO from SVN?  What form of patch: unified diff ok?
Yes x2, but wait until we see if someone else comments on the thread....

Stephen

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message