Barta Tamás created WW-5546: ------------------------------- Summary: NPE in AbstractFileUploadInterceptor Key: WW-5546 URL: https://issues.apache.org/jira/browse/WW-5546 Project: Struts 2 Issue Type: New Feature Components: Core, Core Interceptors Affects Versions: 6.7.4 Reporter: Barta Tamás
I got the following exception: {code:java} 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) {code} I think the bug is is AbstractFileUploadInterceptor: {code:java} 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()) { {code} 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. -- This message was sent by Atlassian Jira (v8.20.10#820010)