https://bz.apache.org/bugzilla/show_bug.cgi?id=57938
Bug ID: 57938 Summary: HttpServletRequest.getString causes NPE when allowCasualMultipartParsing set "true" and multipart field is empty Product: Tomcat 8 Version: 8.0.22 Hardware: PC Status: NEW Severity: major Priority: P2 Component: Util Assignee: dev@tomcat.apache.org Reporter: onurs...@gmail.com Created attachment 32745 --> https://bz.apache.org/bugzilla/attachment.cgi?id=32745&action=edit Sample project to reproduce bug When sending a HTML form as multipart/form-data, if allowCasualMultipartParsing is set to True and any form field is empty, calling HttpServletRequest.getParts() causes NullPointerException. 19-May-2015 23:30:59.912 SEVERE [http-nio-8512-exec-14] org.apache.catalina.core.StandardWrapperValve.invoke Servlet.service() for servlet [post] in context with path [/test] threw exception java.lang.NullPointerException java.lang.String.<init>(String.java:479) org.apache.tomcat.util.http.fileupload.disk.DiskFileItem.getString(DiskFileItem.java:321) org.apache.catalina.connector.Request.parseParts(Request.java:2758) org.apache.catalina.connector.Request.getParts(Request.java:2641) org.apache.catalina.connector.RequestFacade.getParts(RequestFacade.java:1083) com.multipart.emptytest.post.doPost(post.java:25) (<--- HttpServletRequest.getParts() here) javax.servlet.http.HttpServlet.service(HttpServlet.java:648) javax.servlet.http.HttpServlet.service(HttpServlet.java:729) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) ... To Reproduce Bug: 1) Set allowCasualMultipartParsing to "true" in context.xml, 2) Create a HTML form with enctype="multipart/form-data", 3) Submit the form it to a servlet that calls HttpServletRequest.getParts(), 4) If you leave any field empty in the form you will get a NPE. Expected Results: Whether there is an empty field or not HttpServletRequest.getParts() should complete without any exceptions. Empty fields should return empty Part objects. Actual Results: Got NPE. Additional Information: Whether allowCasualMultipartParsing is true or false if the servlet is annotated as @MultipartConfig, error disappears and HttpServletRequest.getParts() behaves as expected. But since sole purpose of allowCasualMultipartParsing is the opportunity of using getParts() in a ServletFilter, this is not a solution. A sample project to reproduce bug in attachment. -- You are receiving this mail because: You are the assignee for the bug. --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org