Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[jetty-users] response.getOutputStream().write() hangs forever if client doesn't consume the response

Hello,

I am creating a simple embedded Jetty server:
  http://pastie.org/9745330

The client is using Apache HttpClient. It doesn't consume the response and exits right after the execute():
  HttpClient client = new DefaultHttpClient();
  HttpGet get = new HttpGet("http://localhost:8080/");
  HttpResponse response = client.execute(get);

Using 8.1.16.v20140903:
If I use response.getOutputStream().write(data), the write() hangs forever and the doGet() method never completes (more than 15 hours).
Now if I use response.getWriter().write(data), the write returns right away (with checkErrors = true).

I am wondering if the OutputStream should not have the same behaviour as the Writer. The Writer seems to have the information about the client being gone, but the OutputStream has no clue and stays stuck.

Interestingly, in version 8.1.0.RC1, the Writer hangs in that scenario as well, and in version 8.1.0.RC2 it returns.
I couldn't find the changelog for RC2 but that change should be applied for the OutputStream as well.

With such a behaviour, it's easy to bring the server to a DOS since the server never releases the resources for that request.

Any idea about this?
I wanted to reach out before opening a BugZilla.

Thanks,
Benjamin

Back to the top