Skip to content

Release the response entity when the client is gone before the server starts writing it #1774

Done

Description

@eskenazit

In 3.0.0-m2, NettyServerCall.sendResponse throws "Connection closed by peer" at its start, before the try/finally that calls Representation.release() on the response entity. handleException then only logs at INFO.

When the response entity wraps a stream from another connection, nothing closes it. Ikanos hits this with streamed binary answers (naftiko/ikanos#1240): the entity is an InputRepresentation over the upstream response body. A client that disconnects while the application waits for the upstream leaves that body open, and the upstream connection stays out of its pool until a timeout.

Release on an error during the write, and on a client leaving mid-stream, already works, since those paths go through the finally.

Expected: the response entity is released whatever the point at which the call fails, including when the peer is gone before the write starts.

Observed with javap -c on org.restlet.engine.netty.NettyServerCall (3.0.0-m2). Related, older and broader: #795.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions