Issue Details (XML | Word | Printable)

Key: MULE-3822
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Dan Diephouse
Reporter: Bill Graham
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
Mule

AbstractReceiverServlet calling httpResponse.setBody(..) twice - causes hanging HTTP client connections

Created: 10/Oct/08 04:39 PM   Updated: 14/Oct/08 12:24 PM
Component/s: Transport: HTTP/ HTTPS
Affects Version/s: 2.1.0
Fix Version/s: 2.0 ITR9, 2.1.1

Time Tracking:
Original Estimate: 1 hour
Original Estimate - 1 hour
Remaining Estimate: 0 minutes
Time Spent - 1 hour
Time Spent: 1 hour
Time Spent - 1 hour

Labels:
User impact: High


 Description  « Hide
In Mule 2.1.0 the following code was added to this method:

org.mule.transport.servlet.AbstractReceiverServlet.writeResponse(HttpServletResponse servletResponse, MuleMessage message)

if (message.getPayload() instanceof InputStream)

{ httpResponse.setBody((OutputHandler) message.getPayload(OutputHandler.class)); }

else

{ httpResponse.setBody(message.getPayloadAsString()); }

This seems like it was intended to replace the previous way of setting the body, which was this line of code:

httpResponse.setBody(message);

The problem though is that both of these are in the current Mule 2.1.0 AbstractReceiverServlet, causing setBody to be called twice. The second setBody is happening a few lines after the first on line 150.

This sets the content length and the output buffer content twice (once before setting the HTTP status, and once after) and causes problems with HTTP requests made with the 'Connection: Keep-Alive' header or requests made without a Connection header (which defaults to Keep-Alive). In this case the output stream isn't received by the client until the HTTP connection finally times out after a minute or so.

I looked in the code a bit, but couldn't pinpoint the exact cause of the problem that creates the symptom I describe, but it nonetheless seems like there's no reason why setBody should be getting called twice. I over-rode the 'writeResponse' method in a servlet of mine (thanks for having it be protected ) and removed the second setBody call, and the problem I was seeing went away. Hence I think this call should be removed.



 All   Comments   Work Log   Change History   Transitions   FishEye      Sort Order: Ascending order - Click to sort in descending order
Dan Diephouse added a comment - 14/Oct/08 08:48 AM
Fixed in: http://fisheye.codehaus.org/changelog/mule/?cs=13062

Thanks Bill for reporting this!