You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by ma...@apache.org on 2003/03/01 22:17:44 UTC
cvs commit: jakarta-commons/fileupload/src/java/org/apache/commons/fileupload DefaultFileItem.java
martinc 2003/03/01 13:17:44
Modified: fileupload/src/java/org/apache/commons/fileupload
DefaultFileItem.java
Log:
Close the input stream after reading the contents.
PR: 17043
Reported by: Faustas Zilinskas
Revision Changes Path
1.15 +20 -5 jakarta-commons/fileupload/src/java/org/apache/commons/fileupload/DefaultFileItem.java
Index: DefaultFileItem.java
===================================================================
RCS file: /home/cvs/jakarta-commons/fileupload/src/java/org/apache/commons/fileupload/DefaultFileItem.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- DefaultFileItem.java 25 Dec 2002 04:05:07 -0000 1.14
+++ DefaultFileItem.java 1 Mar 2003 21:17:44 -0000 1.15
@@ -288,14 +288,29 @@
if (storeLocation != null)
{
content = new byte[(int) getSize()];
+ FileInputStream fis = null;
try
{
- FileInputStream fis = new FileInputStream(storeLocation);
+ fis = new FileInputStream(storeLocation);
fis.read(content);
}
catch (Exception e)
{
content = null;
+ }
+ finally
+ {
+ if (fis != null)
+ {
+ try
+ {
+ fis.close();
+ }
+ catch (IOException e)
+ {
+ // ignore
+ }
+ }
}
}
else
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org