You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@myfaces.apache.org by "Jochen Reinhardt (JIRA)" <de...@myfaces.apache.org> on 2009/05/14 09:14:45 UTC

[jira] Created: (TOMAHAWK-1420) uploadThresholdSize seems to be ignored

uploadThresholdSize seems to be ignored
---------------------------------------

                 Key: TOMAHAWK-1420
                 URL: https://issues.apache.org/jira/browse/TOMAHAWK-1420
             Project: MyFaces Tomahawk
          Issue Type: Bug
          Components: File Upload
    Affects Versions: 1.1.8
         Environment: MyFaces Tomahawk, JSF 1.2 - SUN RI on JBoss 5.01 / integrated Tomcat
            Reporter: Jochen Reinhardt
            Priority: Critical


uploadThresholdSize seems to be ignored. I set it to 0 to get all files saved to disk for further processing in EJB. I also tried with 1 and 1k - but the result stayed the same. I got OutOfMemoryError when uploading huge files as HtmlFileUploadRenderer after line 180 always creeated an instance of UploadedFileDefaultMemoryImpl.

String implementation = ((HtmlInputFileUpload) uiComponent).getStorage();
if( implementation == null || ("memory").equals( implementation ) )
    upFile = new UploadedFileDefaultMemoryImpl( fileItem );
else
    upFile = new UploadedFileDefaultFileImpl( fileItem );

So something seems to be wrong with HtmlInputFileUpload.getStorage() - which uses an EL Expression to get the implementation.But I'm not sure how this is handled in myFaces. The expression just reads:

ValueExpression vb = getValueExpression("storage");

I'm not sure if that is put correctly in the FacesContext. It only works when I use fileUpload's storage attribute to hardcode the strategy to disk in JSF. 

UploadedFileDefaultMemoryImpl always will load the complete file into memory (line 42) - no matter what FileItem / ThresholdingOutputStream is used!

int sizeInBytes = (int)fileItem.getSize();
bytes = new byte[sizeInBytes];
fileItem.getInputStream().read(bytes);

I guess that this is causing my memory issues.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (TOMAHAWK-1420) uploadThresholdSize seems to be ignored

Posted by "Leonardo Uribe (JIRA)" <de...@myfaces.apache.org>.
    [ https://issues.apache.org/jira/browse/TOMAHAWK-1420?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12714540#action_12714540 ] 

Leonardo Uribe commented on TOMAHAWK-1420:
------------------------------------------

Isn't this related to TOMAHAWK-1381? are you using ExtensionsFilter or tomahawk FacesContext wrapper?

> uploadThresholdSize seems to be ignored
> ---------------------------------------
>
>                 Key: TOMAHAWK-1420
>                 URL: https://issues.apache.org/jira/browse/TOMAHAWK-1420
>             Project: MyFaces Tomahawk
>          Issue Type: Bug
>          Components: File Upload
>    Affects Versions: 1.1.8
>         Environment: MyFaces Tomahawk, JSF 1.2 - SUN RI on JBoss 5.01 / integrated Tomcat
>            Reporter: Jochen Reinhardt
>            Priority: Critical
>   Original Estimate: 24h
>  Remaining Estimate: 24h
>
> uploadThresholdSize seems to be ignored. I set it to 0 to get all files saved to disk for further processing in EJB. I also tried with 1 and 1k - but the result stayed the same. I got OutOfMemoryError when uploading huge files as HtmlFileUploadRenderer after line 180 always creeated an instance of UploadedFileDefaultMemoryImpl.
> String implementation = ((HtmlInputFileUpload) uiComponent).getStorage();
> if( implementation == null || ("memory").equals( implementation ) )
>     upFile = new UploadedFileDefaultMemoryImpl( fileItem );
> else
>     upFile = new UploadedFileDefaultFileImpl( fileItem );
> So something seems to be wrong with HtmlInputFileUpload.getStorage() - which uses an EL Expression to get the implementation.But I'm not sure how this is handled in myFaces. The expression just reads:
> ValueExpression vb = getValueExpression("storage");
> I'm not sure if that is put correctly in the FacesContext. It only works when I use fileUpload's storage attribute to hardcode the strategy to disk in JSF. 
> UploadedFileDefaultMemoryImpl always will load the complete file into memory (line 42) - no matter what FileItem / ThresholdingOutputStream is used!
> int sizeInBytes = (int)fileItem.getSize();
> bytes = new byte[sizeInBytes];
> fileItem.getInputStream().read(bytes);
> I guess that this is causing my memory issues.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (TOMAHAWK-1420) uploadThresholdSize seems to be ignored

Posted by "Jochen Reinhardt (JIRA)" <de...@myfaces.apache.org>.
    [ https://issues.apache.org/jira/browse/TOMAHAWK-1420?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12717198#action_12717198 ] 

Jochen Reinhardt commented on TOMAHAWK-1420:
--------------------------------------------

Sorry for the late reply. I am using MyFacesExtensionsFilter - I don't know about FacesContext wrapper. In the end, I am just a user trying to improve things.

For the fileUpload tag - I read the documentation and the recommendation but I decided to give it a try. And it turned out to work fine for me. I never experienced memory problems again after changing this. Thanks for your help - I wish I had found bug 1381 on my own before.

Cheers,
Jochen


> uploadThresholdSize seems to be ignored
> ---------------------------------------
>
>                 Key: TOMAHAWK-1420
>                 URL: https://issues.apache.org/jira/browse/TOMAHAWK-1420
>             Project: MyFaces Tomahawk
>          Issue Type: Bug
>          Components: File Upload
>    Affects Versions: 1.1.8
>         Environment: MyFaces Tomahawk, JSF 1.2 - SUN RI on JBoss 5.01 / integrated Tomcat
>            Reporter: Jochen Reinhardt
>            Assignee: Leonardo Uribe
>            Priority: Critical
>             Fix For: 1.1.9-SNAPSHOT
>
>         Attachments: TOMAHAWK-1420.patch
>
>   Original Estimate: 24h
>  Remaining Estimate: 24h
>
> uploadThresholdSize seems to be ignored. I set it to 0 to get all files saved to disk for further processing in EJB. I also tried with 1 and 1k - but the result stayed the same. I got OutOfMemoryError when uploading huge files as HtmlFileUploadRenderer after line 180 always creeated an instance of UploadedFileDefaultMemoryImpl.
> String implementation = ((HtmlInputFileUpload) uiComponent).getStorage();
> if( implementation == null || ("memory").equals( implementation ) )
>     upFile = new UploadedFileDefaultMemoryImpl( fileItem );
> else
>     upFile = new UploadedFileDefaultFileImpl( fileItem );
> So something seems to be wrong with HtmlInputFileUpload.getStorage() - which uses an EL Expression to get the implementation.But I'm not sure how this is handled in myFaces. The expression just reads:
> ValueExpression vb = getValueExpression("storage");
> I'm not sure if that is put correctly in the FacesContext. It only works when I use fileUpload's storage attribute to hardcode the strategy to disk in JSF. 
> UploadedFileDefaultMemoryImpl always will load the complete file into memory (line 42) - no matter what FileItem / ThresholdingOutputStream is used!
> int sizeInBytes = (int)fileItem.getSize();
> bytes = new byte[sizeInBytes];
> fileItem.getInputStream().read(bytes);
> I guess that this is causing my memory issues.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (TOMAHAWK-1420) uploadThresholdSize seems to be ignored

Posted by "Paulo Henrique Couto de Lima (JIRA)" <de...@myfaces.apache.org>.
    [ https://issues.apache.org/jira/browse/TOMAHAWK-1420?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12714554#action_12714554 ] 

Paulo Henrique Couto de Lima commented on TOMAHAWK-1420:
--------------------------------------------------------

I am using ExtensionsFilter. I think it is not related to TOMAHAWK-1381.

> uploadThresholdSize seems to be ignored
> ---------------------------------------
>
>                 Key: TOMAHAWK-1420
>                 URL: https://issues.apache.org/jira/browse/TOMAHAWK-1420
>             Project: MyFaces Tomahawk
>          Issue Type: Bug
>          Components: File Upload
>    Affects Versions: 1.1.8
>         Environment: MyFaces Tomahawk, JSF 1.2 - SUN RI on JBoss 5.01 / integrated Tomcat
>            Reporter: Jochen Reinhardt
>            Priority: Critical
>   Original Estimate: 24h
>  Remaining Estimate: 24h
>
> uploadThresholdSize seems to be ignored. I set it to 0 to get all files saved to disk for further processing in EJB. I also tried with 1 and 1k - but the result stayed the same. I got OutOfMemoryError when uploading huge files as HtmlFileUploadRenderer after line 180 always creeated an instance of UploadedFileDefaultMemoryImpl.
> String implementation = ((HtmlInputFileUpload) uiComponent).getStorage();
> if( implementation == null || ("memory").equals( implementation ) )
>     upFile = new UploadedFileDefaultMemoryImpl( fileItem );
> else
>     upFile = new UploadedFileDefaultFileImpl( fileItem );
> So something seems to be wrong with HtmlInputFileUpload.getStorage() - which uses an EL Expression to get the implementation.But I'm not sure how this is handled in myFaces. The expression just reads:
> ValueExpression vb = getValueExpression("storage");
> I'm not sure if that is put correctly in the FacesContext. It only works when I use fileUpload's storage attribute to hardcode the strategy to disk in JSF. 
> UploadedFileDefaultMemoryImpl always will load the complete file into memory (line 42) - no matter what FileItem / ThresholdingOutputStream is used!
> int sizeInBytes = (int)fileItem.getSize();
> bytes = new byte[sizeInBytes];
> fileItem.getInputStream().read(bytes);
> I guess that this is causing my memory issues.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (TOMAHAWK-1420) uploadThresholdSize seems to be ignored

Posted by "Joe Knudsen (JIRA)" <de...@myfaces.apache.org>.
    [ https://issues.apache.org/jira/browse/TOMAHAWK-1420?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12723729#action_12723729 ] 

Joe Knudsen commented on TOMAHAWK-1420:
---------------------------------------

This change has made Tomahawk incompatible with File Update 1.1.1 now.  I was getting a java.lang.NoClassDefFoundError: org/apache/commons/fileupload/FileUploadBase$FileSizeLimitExceededException

Then I upgrade to File Upload 1.2.1 and the problem went away.


> uploadThresholdSize seems to be ignored
> ---------------------------------------
>
>                 Key: TOMAHAWK-1420
>                 URL: https://issues.apache.org/jira/browse/TOMAHAWK-1420
>             Project: MyFaces Tomahawk
>          Issue Type: Bug
>          Components: File Upload
>    Affects Versions: 1.1.8
>         Environment: MyFaces Tomahawk, JSF 1.2 - SUN RI on JBoss 5.01 / integrated Tomcat
>            Reporter: Jochen Reinhardt
>            Assignee: Leonardo Uribe
>            Priority: Critical
>             Fix For: 1.1.9
>
>         Attachments: TOMAHAWK-1420.patch
>
>   Original Estimate: 24h
>  Remaining Estimate: 24h
>
> uploadThresholdSize seems to be ignored. I set it to 0 to get all files saved to disk for further processing in EJB. I also tried with 1 and 1k - but the result stayed the same. I got OutOfMemoryError when uploading huge files as HtmlFileUploadRenderer after line 180 always creeated an instance of UploadedFileDefaultMemoryImpl.
> String implementation = ((HtmlInputFileUpload) uiComponent).getStorage();
> if( implementation == null || ("memory").equals( implementation ) )
>     upFile = new UploadedFileDefaultMemoryImpl( fileItem );
> else
>     upFile = new UploadedFileDefaultFileImpl( fileItem );
> So something seems to be wrong with HtmlInputFileUpload.getStorage() - which uses an EL Expression to get the implementation.But I'm not sure how this is handled in myFaces. The expression just reads:
> ValueExpression vb = getValueExpression("storage");
> I'm not sure if that is put correctly in the FacesContext. It only works when I use fileUpload's storage attribute to hardcode the strategy to disk in JSF. 
> UploadedFileDefaultMemoryImpl always will load the complete file into memory (line 42) - no matter what FileItem / ThresholdingOutputStream is used!
> int sizeInBytes = (int)fileItem.getSize();
> bytes = new byte[sizeInBytes];
> fileItem.getInputStream().read(bytes);
> I guess that this is causing my memory issues.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (TOMAHAWK-1420) uploadThresholdSize seems to be ignored

Posted by "Leonardo Uribe (JIRA)" <de...@myfaces.apache.org>.
    [ https://issues.apache.org/jira/browse/TOMAHAWK-1420?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12714667#action_12714667 ] 

Leonardo Uribe commented on TOMAHAWK-1420:
------------------------------------------

I have checked the code related to uploadThresholdSize and everything is fine. This param is passed to org.apache.commons.fileupload.DiskFileUpload. On commons 1.2.1, this class was deprecated, so maybe it is better to use org.apache.commons.fileupload.servlet.ServletFileUpload (the patch attached propose this one). I'm not sure if the patch solves this one, but I'll look in deep the problem to see if something is wrong in HtmlFileUploadRenderer (note this requires a full review of the component).

In the documentation related to getStorage says this:

     * <p>
     * However it appears that this is only half-implemented, and not at all
     * documented. It is therefore recommended that this not be used.
     * </p>

but I suppose do something like:

 t:inputFileUpload storage="disk"

can prevent the OutOfMemory problem.

> uploadThresholdSize seems to be ignored
> ---------------------------------------
>
>                 Key: TOMAHAWK-1420
>                 URL: https://issues.apache.org/jira/browse/TOMAHAWK-1420
>             Project: MyFaces Tomahawk
>          Issue Type: Bug
>          Components: File Upload
>    Affects Versions: 1.1.8
>         Environment: MyFaces Tomahawk, JSF 1.2 - SUN RI on JBoss 5.01 / integrated Tomcat
>            Reporter: Jochen Reinhardt
>            Priority: Critical
>         Attachments: TOMAHAWK-1420.patch
>
>   Original Estimate: 24h
>  Remaining Estimate: 24h
>
> uploadThresholdSize seems to be ignored. I set it to 0 to get all files saved to disk for further processing in EJB. I also tried with 1 and 1k - but the result stayed the same. I got OutOfMemoryError when uploading huge files as HtmlFileUploadRenderer after line 180 always creeated an instance of UploadedFileDefaultMemoryImpl.
> String implementation = ((HtmlInputFileUpload) uiComponent).getStorage();
> if( implementation == null || ("memory").equals( implementation ) )
>     upFile = new UploadedFileDefaultMemoryImpl( fileItem );
> else
>     upFile = new UploadedFileDefaultFileImpl( fileItem );
> So something seems to be wrong with HtmlInputFileUpload.getStorage() - which uses an EL Expression to get the implementation.But I'm not sure how this is handled in myFaces. The expression just reads:
> ValueExpression vb = getValueExpression("storage");
> I'm not sure if that is put correctly in the FacesContext. It only works when I use fileUpload's storage attribute to hardcode the strategy to disk in JSF. 
> UploadedFileDefaultMemoryImpl always will load the complete file into memory (line 42) - no matter what FileItem / ThresholdingOutputStream is used!
> int sizeInBytes = (int)fileItem.getSize();
> bytes = new byte[sizeInBytes];
> fileItem.getInputStream().read(bytes);
> I guess that this is causing my memory issues.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (TOMAHAWK-1420) uploadThresholdSize seems to be ignored

Posted by "Leonardo Uribe (JIRA)" <de...@myfaces.apache.org>.
     [ https://issues.apache.org/jira/browse/TOMAHAWK-1420?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Leonardo Uribe resolved TOMAHAWK-1420.
--------------------------------------

       Resolution: Fixed
    Fix Version/s: 1.1.9-SNAPSHOT
         Assignee: Leonardo Uribe

> uploadThresholdSize seems to be ignored
> ---------------------------------------
>
>                 Key: TOMAHAWK-1420
>                 URL: https://issues.apache.org/jira/browse/TOMAHAWK-1420
>             Project: MyFaces Tomahawk
>          Issue Type: Bug
>          Components: File Upload
>    Affects Versions: 1.1.8
>         Environment: MyFaces Tomahawk, JSF 1.2 - SUN RI on JBoss 5.01 / integrated Tomcat
>            Reporter: Jochen Reinhardt
>            Assignee: Leonardo Uribe
>            Priority: Critical
>             Fix For: 1.1.9-SNAPSHOT
>
>         Attachments: TOMAHAWK-1420.patch
>
>   Original Estimate: 24h
>  Remaining Estimate: 24h
>
> uploadThresholdSize seems to be ignored. I set it to 0 to get all files saved to disk for further processing in EJB. I also tried with 1 and 1k - but the result stayed the same. I got OutOfMemoryError when uploading huge files as HtmlFileUploadRenderer after line 180 always creeated an instance of UploadedFileDefaultMemoryImpl.
> String implementation = ((HtmlInputFileUpload) uiComponent).getStorage();
> if( implementation == null || ("memory").equals( implementation ) )
>     upFile = new UploadedFileDefaultMemoryImpl( fileItem );
> else
>     upFile = new UploadedFileDefaultFileImpl( fileItem );
> So something seems to be wrong with HtmlInputFileUpload.getStorage() - which uses an EL Expression to get the implementation.But I'm not sure how this is handled in myFaces. The expression just reads:
> ValueExpression vb = getValueExpression("storage");
> I'm not sure if that is put correctly in the FacesContext. It only works when I use fileUpload's storage attribute to hardcode the strategy to disk in JSF. 
> UploadedFileDefaultMemoryImpl always will load the complete file into memory (line 42) - no matter what FileItem / ThresholdingOutputStream is used!
> int sizeInBytes = (int)fileItem.getSize();
> bytes = new byte[sizeInBytes];
> fileItem.getInputStream().read(bytes);
> I guess that this is causing my memory issues.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.