[ 
https://issues.apache.org/jira/browse/WW-5751?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18118346#comment-18118346
 ] 

nikos dimitrakas commented on WW-5751:
--------------------------------------

-1 is no good, since the AbstractFileUploadInterceptor has the following if 
condition:
{code:java}
if (policy.getMaximumSize() != null && policy.getMaximumSize() < 
file.length()){code}
I have even tried to create a special getter 
{code:java}
public Long getLongNull() {
   return null;
}{code}
and then used ${longNull}, but that did not help since the method returned null 
and caused the same error.

By the way, 
{code:java}
<param name="myFileUpload.maximumSize">${-1}</param>{code}
and 
{code:java}
<param name="myFileUpload.maximumSize">-1</param>{code}
both succeed in setting the policy.maximumSize, but the second one causes the 
policy.isUnresolved() to be true since -1 is considered a String, and even 
though it is successfully parsed into a Long, it is still setting the 
unresolved flag.

> null can no longer be passed as parameter to interceptor
> --------------------------------------------------------
>
>                 Key: WW-5751
>                 URL: https://issues.apache.org/jira/browse/WW-5751
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Core Interceptors
>    Affects Versions: 7.3.0
>            Reporter: nikos dimitrakas
>            Priority: Major
>             Fix For: 7.5.0
>
>
> Upgrading from 7.2.1 to 7.3.0 seems to have made a change so that null cannot 
> be passed as a parameter to the ActionFileUploadInterceptor.
> I have an interceptor like this:
> {code:java}
> <interceptor name="myFileUpload" 
> class="org.apache.struts2.interceptor.ActionFileUploadInterceptor">
>                 <param name="maximumSize">128000000</param>
> </interceptor>{code}
> That interceptor is then included in a global interceptor stack called 
> myFileUploadStack.
> Later in some specific actions I want to set the maximumSize to null (no 
> limit) and I do this:
> {code:java}
> <interceptor-ref name="myFileUploadStack">
>        <param name="myFileUpload.maximumSize">null</param>
> </interceptor-ref>{code}
> This used to work until 7.2.1, but in 7.3.0 it gives an error:
> The upload validation policy could not be resolved, rejecting the file: file 
> "test.pdf"; unresolved parameters: maximumSize
> Looking at the code and the release notes of 7.3.0, I can find that this 
> probably relates to the changes made in WithLazyParams.java and 
> AbstractFileUploadInterceptor.java (using a policy) as part of WW-5659. But I 
> do not see in the release notes anything about this being intended or what 
> the migration path would be. The javadoc of WithLazyParams.resolveInto() 
> mentions null and empty value becoming unresolved, but not what to do about 
> it.
> Obviously, I can set a very large number or create a second interceptor and 
> interceptorStack to get around this, but I felt that this should be reported 
> so that either it can be fixed, or it can be confirmed as the intended 
> behaviour and if so, perhaps write something about it in the release notes 
> (under Breaking changes) or in a migration guide.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to