olegk 2003/03/16 04:05:03
Modified: httpclient/src/java/org/apache/commons/httpclient/methods/multipart
FilePart.java
Log:
FilePart#sendData method made more protective by using try {} finally {} when
reading from the input stream
Contributed by Oleg Kalnichevski
Revision Changes Path
1.14 +11 -10
jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/methods/multipart/FilePart.java
Index: FilePart.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/methods/multipart/FilePart.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- FilePart.java 26 Feb 2003 02:33:15 -0000 1.13
+++ FilePart.java 16 Mar 2003 12:05:03 -0000 1.14
@@ -294,14 +294,15 @@
byte[] tmp = new byte[4096];
InputStream instream = source.createInputStream();
-
- int len;
- while ((len = instream.read(tmp)) >= 0) {
- out.write(tmp, 0, len);
+ try {
+ int len;
+ while ((len = instream.read(tmp)) >= 0) {
+ out.write(tmp, 0, len);
+ }
+ } finally {
+ // we're done with the stream, close it
+ instream.close();
}
-
- // we're done with the stream, close it
- instream.close();
}
/**
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]