[JBoss JIRA] Commented: (NETTY-187) Subsitute ReplayingDecoder with FrameDecoder without losing stored buffer

Trustin Lee (JIRA) jira-events at lists.jboss.org
Mon Jul 6 06:16:51 EDT 2009


    [ https://jira.jboss.org/jira/browse/NETTY-187?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12474973#action_12474973 ] 

Trustin Lee commented on NETTY-187:
-----------------------------------

I realized that you can substitute a decoder to another with current implementation.

public class FirstDecoder extends FrameDecoder {

    public FirstDecoder() {
        super(true);  // Enable unfold
    }

    protected Object decode(ctx, buf) {
        ...
        // Decode the first message
        Object firstMessage = ...;

        // Add the second decoder
        ctx.getPipeline().addLast("second", new SecondDecoder());

        // Remove the first decoder (me)
        ctx.getPipeline().remove(this);

        if (buf.readable()) {
            // Hand off the remaining data to the second decoder
            return new Object[] { firstMessage, buf.readBytes(buf.readableBytes()) };
        } else {
            // Nothing to hand off
            return firstMessage;
        }
    }
}

This works only when the first decoder is FrameDecoder.  We can't do the same thing for ReplayingDecoder - more investigation needed.

> Subsitute ReplayingDecoder with FrameDecoder without losing stored buffer
> -------------------------------------------------------------------------
>
>                 Key: NETTY-187
>                 URL: https://jira.jboss.org/jira/browse/NETTY-187
>             Project: Netty
>          Issue Type: Feature Request
>          Components: Handler
>    Affects Versions: 3.0.2.GA
>         Environment: Using ubuntu 9.10, java 6
>            Reporter: Miguel Angel Cabrera
>            Assignee: Trustin Lee
>            Priority: Minor
>
> I try to replace a ReplayingDecoder with a FrameDecoder but the buffered data is lost, i would need a mechanism to hand remaining data in buffer to the next handler.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the netty-dev mailing list