You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by "Sven Meier (JIRA)" <ji...@apache.org> on 2016/10/01 21:46:20 UTC
[jira] [Resolved] (WICKET-6250) FileUploadField does not deteach
models and fails to null the reference to the transient fileUploads field
if forceCloseStreamsOnDetach is false
[ https://issues.apache.org/jira/browse/WICKET-6250?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Sven Meier resolved WICKET-6250.
--------------------------------
Resolution: Fixed
Assignee: Sven Meier
Fix Version/s: 7.5.0
8.0.0-M2
6.26
#fileUploads are always cleared now in #onDetach().
Models are *not* set to null though - this is how #forceCloseStreamsOnDetach worked before introduction of multiple file uploads.
> FileUploadField does not deteach models and fails to null the reference to the transient fileUploads field if forceCloseStreamsOnDetach is false
> ------------------------------------------------------------------------------------------------------------------------------------------------
>
> Key: WICKET-6250
> URL: https://issues.apache.org/jira/browse/WICKET-6250
> Project: Wicket
> Issue Type: Bug
> Components: wicket
> Affects Versions: 6.24.0
> Reporter: Torsten Krah
> Assignee: Sven Meier
> Labels: file_upload
> Fix For: 6.26, 8.0.0-M2, 7.5.0
>
>
> FileUpload does not clear our references and its model when the forceCloseStreamsOnDetach is false - which does not match the expectation from the javadoc:
> {code}
> /**
> * The FileUploadField will close any input streams you have opened in its FileUpload by
> * default. If you wish to manage the stream yourself (e.g. you want to use it in another
> * thread) then you can override this method to prevent this behavior.
> *
> * @return <code>true</code> if stream should be closed at the end of request
> */
> {code}
> So it just is about not closing the streams.
> However the fileupload component does not only *not* close the streams - it also *fails* (if you return false from the *forceCloseStreamsOnDetach* method) to reset the model and forget about the current file uploads cached in the transient fileUploads variable.
> {code}
> protected void onDetach()
> {
> if ((fileUploads != null) && forceCloseStreamsOnDetach())
> {
> for (FileUpload fu : fileUploads)
> {
> fu.closeStreams();
> }
> fileUploads = null;
>
> if (getModel() != null)
> {
> getModel().setObject(null);
> }
> }
> super.onDetach();
> }
> {code}
> Shouldn't that read more like this:
> {code}
> protected void onDetach()
> {
> if ((fileUploads != null))
> {
> if(forceCloseStreamsOnDetach() {
> for (FileUpload fu : fileUploads)
> {
> fu.closeStreams();
> }
> }
> fileUploads = null;
>
> if (getModel() != null)
> {
> getModel().setObject(null);
> }
> }
> super.onDetach();
> }
> {code}
> In this case my streams wouldn't be closed but you could provide new streams in the next request.
> As the variable is private and i don't want to close the stream i have to use reflection at the moment to reset the field to null in an overridden onDeteach().
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)