[
https://issues.apache.org/jira/browse/WW-5751?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18118361#comment-18118361
]
Lukasz Lenart commented on WW-5751:
-----------------------------------
You are right, and my {{-1}} suggestion was wrong, sorry about that: {{-1}} is
applied, but then every file is larger than the limit, so every upload is
rejected.
What happened: in 7.2.1 the literal {{null}} was never converted to a null
value. The string {{"null"}} cannot be converted to {{Long}}, and that
conversion error was silently ignored, so {{maximumSize}} kept its default,
which happens to be "no limit". Since 7.3.0 a param value that cannot be
applied is no longer ignored, so the upload is rejected instead.
*Workaround* for 7.3.0 and later: use {{Long.MAX_VALUE}}, which in practice
means no limit:
{code:xml}<interceptor-ref name="myFileUploadStack">
<param name="myFileUpload.maximumSize">9223372036854775807</param>
</interceptor-ref>
{code}
I checked that this value is applied both when the interceptor is created and
when it is invoked.
For the fix I'm going to give "no limit" an explicit value, a negative
{{maximumSize}}, so {{-1}} will do what you first expected. I'll also add this
change to the 7.3.0 Breaking changes notes.
> 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)