Author: olegk
Date: Wed Dec 13 06:19:07 2006
New Revision: 486665

URL: http://svn.apache.org/viewvc?view=rev&rev=486665
Log:
Fix for [HTTPCLIENT-612]: FileRequestEntity in SVN does not close input file

Contributed by Sebastian Bazley
Reviewed by Oleg Kalnichevski

Modified:
    jakarta/commons/proper/httpclient/trunk/release_notes.txt
    
jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/methods/FileRequestEntity.java

Modified: jakarta/commons/proper/httpclient/trunk/release_notes.txt
URL: 
http://svn.apache.org/viewvc/jakarta/commons/proper/httpclient/trunk/release_notes.txt?view=diff&rev=486665&r1=486664&r2=486665
==============================================================================
--- jakarta/commons/proper/httpclient/trunk/release_notes.txt (original)
+++ jakarta/commons/proper/httpclient/trunk/release_notes.txt Wed Dec 13 
06:19:07 2006
@@ -1,5 +1,8 @@
 Changes since Release 3.1 Beta 1:
 
+* [HTTPCLIENT-612] - FileRequestEntity now always closes the input file.
+           Contributed by Sebastian Bazley <sebb at apache.org>
+
 * [HTTPCLIENT-616] - HttpMethodDirector.executeWithRetry method fixed to close 
the 
            underlying connection if a RuntimeException is thrown
            Contributed by Jason Bird

Modified: 
jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/methods/FileRequestEntity.java
URL: 
http://svn.apache.org/viewvc/jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/methods/FileRequestEntity.java?view=diff&rev=486665&r1=486664&r2=486665
==============================================================================
--- 
jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/methods/FileRequestEntity.java
 (original)
+++ 
jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/methods/FileRequestEntity.java
 Wed Dec 13 06:19:07 2006
@@ -71,9 +71,13 @@
         byte[] tmp = new byte[4096];
         int i = 0;
         InputStream instream = new FileInputStream(this.file);
-        while ((i = instream.read(tmp)) >= 0) {
-            out.write(tmp, 0, i);
-        }        
+        try {
+            while ((i = instream.read(tmp)) >= 0) {
+                out.write(tmp, 0, i);
+            }        
+        } finally {
+            instream.close();
+        }
     }    
     
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to