commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject cvs commit: jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/methods/multipart FilePart.java
Date Sun, 16 Mar 2003 12:05:03 GMT
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: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message