Hello,

I've been streaming data using a ReadableRepresentation sourced from a nio Pipe 
with the sink attached to a writer thread, but couldn't get the sink end of the 
pipe to close upon a client's disconnect.

ReadableRepresentation seems to set its reference to the ReadableByteChannel to 
null in getChannel() so the entity's release in the finally block in 
HttpServerCall's sendResponse never closes the channel (which would be needed 
to trigger an IOException when writing to the Pipe's sink so I could detect a 
disconnect).

Is this intended behaviour or would it be possible to not null the reference so 
the channel would close?

Thanks, 
Janne Husberg.

Patched ReadableRepresentation.java (1.2M1/SVN r4163):
    @Override
    public ReadableByteChannel getChannel() throws IOException {
        final ReadableByteChannel result = this.channel;
//        this.channel = null;
        setAvailable(false);
        return result;
    }

    /**
     * Closes and releases the readable channel.
     */
    @Override
    public void release() {
        if (this.channel != null) {
            try {
                this.channel.close();
            } catch (IOException e) {
                Context.getCurrentLogger().log(Level.WARNING,
                        "Error while releasing the representation.", e);
            }

            this.channel = null;
        }
        super.release();
    }

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=1077335

Reply via email to