[jboss-remoting-issues] [JBoss JIRA] Resolved: (JBREM-1251) WriterOutputStream.write() won't call doFlush() until the ByteBuffer is full

Ron Sigal (JIRA) jira-events at lists.jboss.org
Fri Nov 12 13:00:36 EST 2010


     [ https://jira.jboss.org/browse/JBREM-1251?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Ron Sigal resolved JBREM-1251.
------------------------------

      Assignee: Ron Sigal
    Resolution: Done


Added a STREAM_FLUSH facility:

1. added RemoteProtocol.STREAM_FLUSH

2. added OutboundStream.getFlushBuffer(), which creates a buffer initialized with RemoteProtocol.STREAM_FLUSH

3. updated flush() in NioByteOutput returned by PrimaryExternalizerFactory.readOutboundStream() to

            public void flush() throws IOException {
                ByteBuffer flushBuffer = outboundStream.getFlushBuffer();
                flushBuffer.flip();
                outboundStream.send(flushBuffer);
            }

4. In InboundStream

    a. added flush() to Receiver interface

    b. added

        public void flush() {
        }

        to InboundStream.NioByteInputReceiver

    c. added

        public void flush() {
            try {
                outputStream.flush();
            } catch (IOException e) {
                log.trace("Output stream write failed: %s", e);
                sendAsyncException();
            }
        }

        to InboundStream.OutputStreamReceiver

5. In WriterOutputStream, changed

    public void flush() throws IOException {
        if (closed) throw new IOException("Stream closed");
        writer.flush();
    }

to

    public void flush() throws IOException {
        if (closed) throw new IOException("Stream closed");
        doFlush(false);
    }

so that all received bytes go into the Writer

6.  Added

            case RemoteProtocol.STREAM_FLUSH: {
                log.info(this + " got STREAM_FLUSH");
                final int sid = buffer.getInt();
                final IntKeyMap<InboundStream> inboundStreams = connectionHandler.getInboundStreams();
                final InboundStream inboundStream;
                synchronized (inboundStreams) {
                    inboundStream = inboundStreams.get(sid);
                }
                if (inboundStream == null) {
                    log.warn("Received stream-flush for unknown stream ID %d", Integer.valueOf(sid));
                    return;
                }
                inboundStream.getReceiver().flush();
                return;
            }

RemoteMessageHandler. 

> WriterOutputStream.write() won't call doFlush() until the ByteBuffer is full
> ----------------------------------------------------------------------------
>
>                 Key: JBREM-1251
>                 URL: https://jira.jboss.org/browse/JBREM-1251
>             Project: JBoss Remoting
>          Issue Type: Bug
>      Security Level: Public(Everyone can see) 
>          Components: stream
>    Affects Versions: 3.1.0.Beta2
>            Reporter: Ron Sigal
>            Assignee: Ron Sigal
>             Fix For: 3.1.0.Beta3
>
>
> If a client sends a java.io.Writer and the org.jboss.remoting3.RequestListener writes a short message to it and flushes, the message isn't available on the client side. org.jboss.remoting3.stream.WriterOutputStream.write() won't call doFlush() until the ByteBuffer is full.  So the RequestHandler has to close the writer, and then WriterOutputStream.close() will call doFlush().
> WriterOutputStream.write() should be flushing.  Also, the behavior should be consistent with OutputStream.

-- 
This message is automatically generated by JIRA.
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the jboss-remoting-issues mailing list