jetty / jetty.project

Eclipse Jetty® - Web Container & Clients - supports HTTP/2, HTTP/1.1, HTTP/1.0, websocket, servlets, and more
https://eclipse.dev/jetty
Other
3.79k stars 1.91k forks source link

NullPointerException on complianceViolationListener when uploading multipart file #11929

Open cyin869 opened 2 weeks ago

cyin869 commented 2 weeks ago

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
janbartel commented 2 weeks ago

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?

cyin869 commented 2 weeks ago

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.