You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by "Attila Király (JIRA)" <ji...@apache.org> on 2010/06/13 21:12:14 UTC
[jira] Created: (WICKET-2913)
o.a.w.markup.html.form.upload.FileUpload.writeTo(File) is not optimal
o.a.w.markup.html.form.upload.FileUpload.writeTo(File) is not optimal
---------------------------------------------------------------------
Key: WICKET-2913
URL: https://issues.apache.org/jira/browse/WICKET-2913
Project: Wicket
Issue Type: Improvement
Components: wicket
Affects Versions: 1.4.9
Reporter: Attila Király
The current code of org.apache.wicket.markup.html.form.upload.FileUpload.writeTo(File):
public void writeTo(final File file) throws IOException
{
writeTo(file, 4096);
}
simply delegates to org.apache.wicket.markup.html.form.upload.FileUpload.writeTo(File, int):
public void writeTo(final File file, final int bufSize) throws IOException
{
InputStream is = getInputStream();
try
{
Files.writeTo(file, is, bufSize);
}
finally
{
is.close();
}
}
which opens an inputstream and pumbs the content to the parameter file. This means that there is always a copy.
But if writeTo(File) would look something like this:
public void writeTo(final File file) throws IOException
{
item.write(file);
// item.write can throw Exception so some exception handling is also needed (rethrow as IOException maybe)
}
This could be more efficient because item is a FileItem which is probably a DiskFileItem (the only implementation in wicket), and DiskFileItem.write() tries to simply rename the file first. If that fails it tries to copy. So if rename works there is no need to copy and the code runs faster.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.