You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@excalibur.apache.org by le...@apache.org on 2004/06/18 11:13:00 UTC
svn commit: rev 21411 - excalibur/trunk/compatibility/src/java/org/apache/avalon/excalibur/io
Author: leif
Date: Fri Jun 18 02:12:59 2004
New Revision: 21411
Modified:
excalibur/trunk/compatibility/src/java/org/apache/avalon/excalibur/io/FileUtil.java
Log:
If an exception was thrown while copying files then both
the input and output streams were being left open. Code review.
Modified: excalibur/trunk/compatibility/src/java/org/apache/avalon/excalibur/io/FileUtil.java
==============================================================================
--- excalibur/trunk/compatibility/src/java/org/apache/avalon/excalibur/io/FileUtil.java (original)
+++ excalibur/trunk/compatibility/src/java/org/apache/avalon/excalibur/io/FileUtil.java Fri Jun 18 02:12:59 2004
@@ -384,11 +384,24 @@
throw new IOException( message );
}
+ // Make sure that any opened streams are always closed.
final FileInputStream input = new FileInputStream( source );
- final FileOutputStream output = new FileOutputStream( destination );
- IOUtil.copy( input, output );
- IOUtil.shutdownStream( input );
- IOUtil.shutdownStream( output );
+ try
+ {
+ final FileOutputStream output = new FileOutputStream( destination );
+ try
+ {
+ IOUtil.copy( input, output );
+ }
+ finally
+ {
+ IOUtil.shutdownStream( output );
+ }
+ }
+ finally
+ {
+ IOUtil.shutdownStream( input );
+ }
if( source.length() != destination.length() )
{
---------------------------------------------------------------------
To unsubscribe, e-mail: scm-unsubscribe@excalibur.apache.org
For additional commands, e-mail: scm-help@excalibur.apache.org