Re: NPE in StrutsUploadedFile

2025-05-05 Thread Lukasz Lenart
PR is ready for review
https://github.com/apache/struts/pull/1262

wt., 29 kwi 2025 o 19:13 Lukasz Lenart  napisał(a):
>
> wt., 29 kwi 2025 o 14:59 Tamás Barta  napisał(a):
> > Lukas, could you please fix this bug?
>
> Sure, please register a ticket :)
>
>
> Cheers
> Łukasz

-
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]



Re: NPE in StrutsUploadedFile

2025-04-29 Thread Lukasz Lenart
wt., 29 kwi 2025 o 14:59 Tamás Barta  napisał(a):
> Lukas, could you please fix this bug?

Sure, please register a ticket :)


Cheers
Łukasz

-
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]



Re: NPE in StrutsUploadedFile

2025-04-29 Thread Tamás Barta
Hi!

I'm afraid I can't and the action class itself is not relevant here,
because it isn't called yet.
Before the ERROR log (the stacktrace) there is only one log line with empty
message:

2025-04-29 10:08:21,810 WARN
 [org.apache.struts2.interceptor.AbstractFileUploadInterceptor] (default
task-13179/Yngvbmgw08HwnX2JfPmo9KJy8gPw1-JJxe9bMmoh)

I think I found the bug in AbstractFileUploadInterceptor, the related lines:

if (file.getContent() == null) {

String errMsg = getTextMessage(action, STRUTS_MESSAGES_ERROR_UPLOADING_KEY,
new String[]{originalFilename});

errorMessages.add(errMsg);

LOG.warn(errMsg);

}

if (maximumSize != null && maximumSize < file.length()) {


If file.getContent() is null (which means StrutsUploadedFile.file is null),
then warning is logged but there is no "return false" so execution
continues and file.length() will throw NPE as file is null
in StrutsUploadedFile.

Lukas, could you please fix this bug?

Regards, Tamás

On Tue, Apr 29, 2025 at 2:19 PM M Huzaifah  wrote:

> Hii Tamás,
>
> Could you please attach your action class, so all of us in here can
> see the details.
>
> Thank you
>
> On Tue, Apr 29, 2025 at 7:00 PM Tamás Barta  wrote:
> >
> > Hi!
> >
> > We use Struts 6.7.4 and today we got the following exception in our
> > production system. I don't know how it is possible or how to reproduce it
> > or how to avoid it. Do you have any ideas? Of course it was a POST with
> > file upload.
> >
> > java.lang.NullPointerException: Cannot invoke "java.io.File.length()"
> > because "this.file" is null
> > at
> >
> deployment.deployment.ear//org.apache.struts2.dispatcher.multipart.StrutsUploadedFile.length(StrutsUploadedFile.java:52)
> > at
> >
> deployment.deployment.ear//org.apache.struts2.interceptor.AbstractFileUploadInterceptor.acceptFile(AbstractFileUploadInterceptor.java:133)
> > at
> >
> deployment.deployment.ear//org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:232)
> > at
> >
> deployment.deployment.ear//com.opensymphony.xwork2.interceptor.AbstractInterceptor.intercept(AbstractInterceptor.java:36)
> > at
> >
> deployment.deployment.ear//com.opensymphony.xwork2.DefaultActionInvocation.executeConditional(DefaultActionInvocation.java:303)
> > at
> >
> deployment.deployment.ear//com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:257)
> > at
> >
> deployment.deployment.ear//com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:104)
> > at
> >
> deployment.deployment.ear//com.opensymphony.xwork2.interceptor.AbstractInterceptor.intercept(AbstractInterceptor.java:36)
> > at
> >
> deployment.deployment.ear//com.opensymphony.xwork2.DefaultActionInvocation.executeConditional(DefaultActionInvocation.java:303)
> > at
> >
> deployment.deployment.ear//com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:257)
> > at
> >
> deployment.deployment.ear//com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:169)
> > at
> >
> deployment.deployment.ear//com.opensymphony.xwork2.interceptor.AbstractInterceptor.intercept(AbstractInterceptor.java:36)
> > at
> >
> deployment.deployment.ear//com.opensymphony.xwork2.DefaultActionInvocation.executeConditional(DefaultActionInvocation.java:303)
> > at
> >
> deployment.deployment.ear//com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:257)
> > at
> >
> deployment.deployment.ear//org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:154)
> > at
> >
> deployment.deployment.ear//com.opensymphony.xwork2.interceptor.AbstractInterceptor.intercept(AbstractInterceptor.java:36)
> > at
> >
> deployment.deployment.ear//com.opensymphony.xwork2.DefaultActionInvocation.executeConditional(DefaultActionInvocation.java:303)
> > at
> >
> deployment.deployment.ear//com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:257)
> > at
> >
> deployment.deployment.ear//com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:199)
> > at
> >
> deployment.deployment.ear//com.opensymphony.xwork2.interceptor.AbstractInterceptor.intercept(AbstractInterceptor.java:36)
> > at
> >
> deployment.deployment.ear//com.opensymphony.xwork2.DefaultActionInvocation.executeConditional(DefaultActionInvocation.java:303)
> > at
> >
> deployment.deployment.ear//com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:257)
> > ...
> >
> > Thanks, Tamás
>
> -
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>


Re: NPE in StrutsUploadedFile

2025-04-29 Thread M Huzaifah
Hii Tamás,

Could you please attach your action class, so all of us in here can
see the details.

Thank you

On Tue, Apr 29, 2025 at 7:00 PM Tamás Barta  wrote:
>
> Hi!
>
> We use Struts 6.7.4 and today we got the following exception in our
> production system. I don't know how it is possible or how to reproduce it
> or how to avoid it. Do you have any ideas? Of course it was a POST with
> file upload.
>
> java.lang.NullPointerException: Cannot invoke "java.io.File.length()"
> because "this.file" is null
> at
> deployment.deployment.ear//org.apache.struts2.dispatcher.multipart.StrutsUploadedFile.length(StrutsUploadedFile.java:52)
> at
> deployment.deployment.ear//org.apache.struts2.interceptor.AbstractFileUploadInterceptor.acceptFile(AbstractFileUploadInterceptor.java:133)
> at
> deployment.deployment.ear//org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:232)
> at
> deployment.deployment.ear//com.opensymphony.xwork2.interceptor.AbstractInterceptor.intercept(AbstractInterceptor.java:36)
> at
> deployment.deployment.ear//com.opensymphony.xwork2.DefaultActionInvocation.executeConditional(DefaultActionInvocation.java:303)
> at
> deployment.deployment.ear//com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:257)
> at
> deployment.deployment.ear//com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:104)
> at
> deployment.deployment.ear//com.opensymphony.xwork2.interceptor.AbstractInterceptor.intercept(AbstractInterceptor.java:36)
> at
> deployment.deployment.ear//com.opensymphony.xwork2.DefaultActionInvocation.executeConditional(DefaultActionInvocation.java:303)
> at
> deployment.deployment.ear//com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:257)
> at
> deployment.deployment.ear//com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:169)
> at
> deployment.deployment.ear//com.opensymphony.xwork2.interceptor.AbstractInterceptor.intercept(AbstractInterceptor.java:36)
> at
> deployment.deployment.ear//com.opensymphony.xwork2.DefaultActionInvocation.executeConditional(DefaultActionInvocation.java:303)
> at
> deployment.deployment.ear//com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:257)
> at
> deployment.deployment.ear//org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:154)
> at
> deployment.deployment.ear//com.opensymphony.xwork2.interceptor.AbstractInterceptor.intercept(AbstractInterceptor.java:36)
> at
> deployment.deployment.ear//com.opensymphony.xwork2.DefaultActionInvocation.executeConditional(DefaultActionInvocation.java:303)
> at
> deployment.deployment.ear//com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:257)
> at
> deployment.deployment.ear//com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:199)
> at
> deployment.deployment.ear//com.opensymphony.xwork2.interceptor.AbstractInterceptor.intercept(AbstractInterceptor.java:36)
> at
> deployment.deployment.ear//com.opensymphony.xwork2.DefaultActionInvocation.executeConditional(DefaultActionInvocation.java:303)
> at
> deployment.deployment.ear//com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:257)
> ...
>
> Thanks, Tamás

-
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]