jetty / jetty.project

Eclipse Jetty® - Web Container & Clients - supports HTTP/2, HTTP/1.1, HTTP/1.0, websocket, servlets, and more

Home Page:https://eclipse.dev/jetty

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

NullPointerException on complianceViolationListener when uploading multipart file

cyin869 opened this issue · comments

Jetty version(s)
jetty 12.0.10

Jetty Environment
ee10

Java version/vendor (use: java -version)
GAE java 21

OS type/version
Ubuntu-1ubuntu122.04.1

Description
When uploading a multipart file, we are getting a NullPointerException. Tracing the source, it looks like the compliance or complianceListener is null. This was working in jetty 9, but stopped working after upgrading with jetty 12. I'm not sure if I am missing anything. We are using springboot 3.3.0 to get the multipart files, and this is hosted on GAE.

compliance = Objects.requireNonNull(multiPartCompliance);
-->  complianceListener = Objects.requireNonNull(complianceViolationListener);
Caused by: org.eclipse.jetty.http.BadMessageException: 400: bad multipart
	... 118 more
Caused by: java.lang.NullPointerException
	at java.base/java.util.Objects.requireNonNull(Objects.java:233)
	at org.eclipse.jetty.http.MultiPartFormData$Parser.<init>(MultiPartFormData.java:240)
	at org.eclipse.jetty.http.MultiPartFormData.from(MultiPartFormData.java:105)
	at org.eclipse.jetty.ee10.servlet.ServletMultiPartFormData.from(ServletMultiPartFormData.java:111)
	at org.eclipse.jetty.ee10.servlet.ServletMultiPartFormData.from(ServletMultiPartFormData.java:63)
	at org.eclipse.jetty.ee10.servlet.ServletApiRequest.getParts(ServletApiRequest.java:637)
	... 117 more

This is the formData posted and the request headers contains the multipart/form-data

------WebKitFormBoundaryqsV4JTTsifltJG52
Content-Disposition: form-data; name="file"; filename="Screenshot 2023-11-20 144643.jpg"
Content-Type: image/jpeg


------WebKitFormBoundaryqsV4JTTsifltJG52--

Content-Length: 108409
Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryqsV4JTTsifltJG52

Odd, I can see code that is checking the ComplianceViolationListeners set in the HttpConfiguration and if none are set, it is set to a default, no-op instance. I can't immediately see how it can be null. Can you post more of your configuration please?

We are deploying on Google app engine so I don't really have a configuration that I can post. I tried to remove all the Google dependencies and deploy a pure springboot app with jetty 12 and I actually do not get the NullPointersExceptions. I suspect Google may have some custom configurations that is conflicting when they are setting up their version. I will raise a ticket with Google.

Thanks.

@cyin869 ok, I'll close this as an issue for jetty for now.

@cyin869 Workaround - org.apache.commons.fileupload2.jakarta.servlet6.JakartaServletFileUpload

implementation 'org.apache.commons:commons-fileupload2-jakarta-servlet6:2.0.0-M2'