commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Stephen Colebourne" <>
Subject Re: [io] copyAndClose
Date Tue, 08 Feb 2005 00:37:23 GMT
From: "B. K. Oxley (binkley)" <>
> 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....


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message