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/09/28 16:47:42 UTC

svn commit: rev 47401 - excalibur/trunk/components/sourceresolve/src/java/org/apache/excalibur/source

Author: leif
Date: Tue Sep 28 07:47:41 2004
New Revision: 47401

Modified:
   excalibur/trunk/components/sourceresolve/src/java/org/apache/excalibur/source/SourceUtil.java
Log:
If multiple exceptions are thrown while in the copy method, make sure that the original exception is reported rather than the final one.

Modified: excalibur/trunk/components/sourceresolve/src/java/org/apache/excalibur/source/SourceUtil.java
==============================================================================
--- excalibur/trunk/components/sourceresolve/src/java/org/apache/excalibur/source/SourceUtil.java	(original)
+++ excalibur/trunk/components/sourceresolve/src/java/org/apache/excalibur/source/SourceUtil.java	Tue Sep 28 07:47:41 2004
@@ -500,6 +500,7 @@
                                           "' is not writeable");
             }
             
+            IOException firstE = null;
             ModifiableSource modDestination = (ModifiableSource)destination;
             try
             {
@@ -515,14 +516,16 @@
                         }
                         catch ( IOException e )
                         {
+                            // Remebver the original exception in case there are problems closing
+                            //  any streams.
+                            firstE = e;
+                            
+                            // If possible, cancel the destination.
                             if ( modDestination.canCancel( out ) )
                             {
                                 modDestination.cancel( out );
                                 out = null;
                             }
-                            
-                            // Rethrow the exception.  It will be recaught below.
-                            throw e;
                         }
                     }
                     finally
@@ -539,10 +542,19 @@
                     in.close();
                 }
             } catch (IOException ioe) {
+                if ( firstE == null )
+                {
+                    firstE = ioe;
+                }
+            }
+            
+            // If there were any problems then wrap the original exception in a SourceException.
+            if ( firstE != null )
+            {
                 throw new SourceException("Could not copy source '"+
                                           source.getURI()+"' to '"+
                                           destination.getURI()+"' :"+
-                                          ioe.getMessage(), ioe);
+                                          firstE.getMessage(), firstE);
             }
         }
     }

---------------------------------------------------------------------
To unsubscribe, e-mail: scm-unsubscribe@excalibur.apache.org
For additional commands, e-mail: scm-help@excalibur.apache.org