You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by "Peter Ertl (JIRA)" <ji...@apache.org> on 2010/12/02 02:18:11 UTC
[jira] Resolved: (WICKET-2913)
o.a.w.markup.html.form.upload.FileUpload.writeTo(File) is not optimal
[ https://issues.apache.org/jira/browse/WICKET-2913?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Peter Ertl resolved WICKET-2913.
--------------------------------
Resolution: Duplicate
Fix Version/s: 1.5-M4
Assignee: Peter Ertl
should be fixed with WICKET-2833. The internal handling of FileUpload was also reworked.
> 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
> Assignee: Peter Ertl
> Fix For: 1.5-M4
>
>
> 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.