Skip to content

Fix NPE in ee9/ee8 nested.BufferedResponesHandler #13640

@joakime

Description

@joakime

Jetty version(s)
12.1.0

Jetty Environment
ee8 and ee9

HTTP version
Any

Java version/vendor (use: java -version)
Any

OS type/version
Any

Description
If using the nested.BufferedResponseHandler in ee8/ee9 it is possible to trigger a NPE if the following sequence of events occur.

Note: this is not an issue present in the Jetty Core org.eclipse.jetty.server.handler.BufferedResponseHandler (a different class)

new HttpServlet()
{
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException
    {
        resp.setStatus(400);
        resp.flushBuffer();
        resp.getOutputStream().close();
    }
}
  1. Don't write response content.
  2. Set the status code.
  3. Flush the response buffers.
  4. Manually close the response outputstream.

This messes up the BufferedResponseHandler internal state tracking if an aggregate buffer has been used or not.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugFor general bugs on Jetty sideSponsoredThis issue affects a user with a commercial support agreement

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions