On 15 February 2014 21:29, Bernd Eckenfels <[email protected]> wrote:
> Am Sat, 15 Feb 2014 21:18:43 -0000
> schrieb [email protected]:
>
>> Author: sebb
>> Date: Sat Feb 15 21:18:42 2014
>> New Revision: 1568678
>>
>> URL: http://svn.apache.org/r1568678
>> Log:
>> FILEUPLOAD-245 DiskFileItem.get() may not fully read the data
>>
>> Modified:
>> commons/proper/fileupload/trunk/src/changes/changes.xml
>>
>> commons/proper/fileupload/trunk/src/main/java/org/apache/commons/fileupload/disk/DiskFileItem.java
>>
>> Modified: commons/proper/fileupload/trunk/src/changes/changes.xml
>> URL:
>> http://svn.apache.org/viewvc/commons/proper/fileupload/trunk/src/changes/changes.xml?rev=1568678&r1=1568677&r2=1568678&view=diff
>> ==============================================================================
>> --- commons/proper/fileupload/trunk/src/changes/changes.xml
>> (original) +++
>> commons/proper/fileupload/trunk/src/changes/changes.xml Sat Feb 15
>> 21:18:42 2014 @@ -45,7 +45,8 @@ The <action> type attribute can be
>> add,u <body> <release version="1.4" date="TBA" description= "TBA">
>> - <action dev="sebb" type="update" due-to="Ville Skyttä">Make
>> some MultipartStream private fields final</action>
>> + <action issue="FILEUPLOAD-245" dev="sebb"
>> type="fix">DiskFileItem.get() may not fully read the data</action>
>> + <action issue="FILEUPLOAD-243" dev="sebb" type="update"
>> due-to="Ville Skyttä">Make some MultipartStream private fields
>> final</action> </release>
>> <release version="1.3.1" description=
>>
>> Modified:
>> commons/proper/fileupload/trunk/src/main/java/org/apache/commons/fileupload/disk/DiskFileItem.java
>> URL:
>> http://svn.apache.org/viewvc/commons/proper/fileupload/trunk/src/main/java/org/apache/commons/fileupload/disk/DiskFileItem.java?rev=1568678&r1=1568677&r2=1568678&view=diff
>> ==============================================================================
>> ---
>> commons/proper/fileupload/trunk/src/main/java/org/apache/commons/fileupload/disk/DiskFileItem.java
>> (original) +++
>> commons/proper/fileupload/trunk/src/main/java/org/apache/commons/fileupload/disk/DiskFileItem.java
>> Sat Feb 15 21:18:42 2014 @@ -312,7 +312,7 @@ public class
>> DiskFileItem try { fis = new BufferedInputStream(new
>> FileInputStream(dfos.getFile()));
>> - fis.read(fileData);
>> + IOUtils.readFully(fis, fileData);
>
> There is no need to buffer the Streams if you are going
> to read with large (maximum) buffers.
That could be changed, but is a separate issue from ensuring that the
data is read fully.
> I also wonder if this is really a
> good idea to read the data fully into memory, only to stream it then to
> somewhere else.
The method in question returns the content of the file as an array of bytes.
It is a public method, so the API cannot readily be changed.
>
>> } catch (IOException e) {
>> fileData = null;
>> } finally {
>> @@ -681,9 +681,11 @@ public class DiskFileItem
>> if (cachedContent != null) {
>> output.write(cachedContent);
>> } else {
>> + new Throwable(dfosFile.toString()).printStackTrace();
>> FileInputStream input = new FileInputStream(dfosFile);
>> IOUtils.copy(input, output);
>> - dfosFile.delete();
>> + input.close();
>> + System.out.println("deleted?"+dfosFile.delete()+"
>> "+dfosFile); dfosFile = null;
>
> Debug code?
Oops, good catch.
> Bernd
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]