<div dir="ltr">So, I had a chat with trustin over IRC. You do need to skipBytes or reposition the reader index to the originalReaderIndex + length if in your exception handler you don&#39;t close the connection.<div><div><br>

</div><div>Shay<br><br><div class="gmail_quote">On Thu, May 13, 2010 at 8:32 PM, Johnny Luong <span dir="ltr">&lt;<a href="mailto:johnny.luong@trustcommerce.com">johnny.luong@trustcommerce.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

Class FrameDecoder;<br>
<br>
<a href="http://docs.jboss.org/netty/3.1/api/org/jboss/netty/handler/codec/frame/FrameDecoder.html" target="_blank">http://docs.jboss.org/netty/3.1/api/org/jboss/netty/handler/codec/frame/FrameDecoder.html</a><br>
<div><div></div><div class="h5"><br>
<br>
Shay Banon wrote:<br>
&gt; Where is it exactly?<br>
&gt;<br>
&gt; On Thu, May 13, 2010 at 4:33 AM, Johnny Luong &lt;<br>
&gt; <a href="mailto:johnny.luong@trustcommerce.com">johnny.luong@trustcommerce.com</a>&gt; wrote:<br>
&gt;<br>
&gt;&gt; Hi Shay,<br>
&gt;&gt;<br>
&gt;&gt; I think the example provided in the javadoc under Decoder Implementation<br>
&gt;&gt; is what your trying to do and provides clarity...<br>
&gt;&gt;<br>
&gt;&gt; <a href="http://docs.jboss.org/netty/3.1/api/" target="_blank">http://docs.jboss.org/netty/3.1/api/</a><br>
&gt;&gt;<br>
&gt;&gt; Best,<br>
&gt;&gt; Johnny<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; Shay Banon wrote:<br>
&gt;&gt;&gt; Hi,<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;    I have a problem and am trying to find the best solution for. In<br>
&gt;&gt; netty, I<br>
&gt;&gt;&gt; am using a FrameDecoder that simply does the following:<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;     protected Object decode(ChannelHandlerContext ctx, Channel channel,<br>
&gt;&gt;&gt; ChannelBuffer buffer) throws Exception {<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;         if (buffer.readableBytes() &lt; 4) {<br>
&gt;&gt;&gt;             return null;<br>
&gt;&gt;&gt;         }<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;         int dataLen = buffer.getInt(buffer.readerIndex());<br>
&gt;&gt;&gt;         if (dataLen &lt;= 0) {<br>
&gt;&gt;&gt;             throw new StreamCorruptedException(&quot;invalid data length: &quot; +<br>
&gt;&gt;&gt; dataLen);<br>
&gt;&gt;&gt;         }<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;         if (buffer.readableBytes() &lt; dataLen + 4) {<br>
&gt;&gt;&gt;             return null;<br>
&gt;&gt;&gt;         }<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;         buffer.skipBytes(4);<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;         return buffer;<br>
&gt;&gt;&gt;     }<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; On the next handler, I use the buffer to extract the request from (and<br>
&gt;&gt; other<br>
&gt;&gt;&gt; information). The problem I have is that something might fail and I won&#39;t<br>
&gt;&gt;&gt; read the whole buffer. In this case, things gets corrupted for requests<br>
&gt;&gt; that<br>
&gt;&gt;&gt; follow. Once I do read the whole buffer, things works correctly. I can<br>
&gt;&gt;&gt; skipBytes in the size of (writerIndex - readerIndex) in case of an<br>
&gt;&gt;&gt; exception, but then I wonder how does the built in ObjectDecoder handles<br>
&gt;&gt;&gt; this case..., maybe I am missing something?<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; cheers,<br>
&gt;&gt;&gt; shay.banon<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; ------------------------------------------------------------------------<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; _______________________________________________<br>
&gt;&gt;&gt; netty-users mailing list<br>
&gt;&gt;&gt; <a href="mailto:netty-users@lists.jboss.org">netty-users@lists.jboss.org</a><br>
&gt;&gt;&gt; <a href="https://lists.jboss.org/mailman/listinfo/netty-users" target="_blank">https://lists.jboss.org/mailman/listinfo/netty-users</a><br>
&gt;&gt; _______________________________________________<br>
&gt;&gt; netty-users mailing list<br>
&gt;&gt; <a href="mailto:netty-users@lists.jboss.org">netty-users@lists.jboss.org</a><br>
&gt;&gt; <a href="https://lists.jboss.org/mailman/listinfo/netty-users" target="_blank">https://lists.jboss.org/mailman/listinfo/netty-users</a><br>
&gt;&gt;<br>
&gt;<br>
&gt;<br>
&gt; ------------------------------------------------------------------------<br>
&gt;<br>
&gt; _______________________________________________<br>
&gt; netty-users mailing list<br>
&gt; <a href="mailto:netty-users@lists.jboss.org">netty-users@lists.jboss.org</a><br>
&gt; <a href="https://lists.jboss.org/mailman/listinfo/netty-users" target="_blank">https://lists.jboss.org/mailman/listinfo/netty-users</a><br>
<br>
_______________________________________________<br>
netty-users mailing list<br>
<a href="mailto:netty-users@lists.jboss.org">netty-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/netty-users" target="_blank">https://lists.jboss.org/mailman/listinfo/netty-users</a><br>
</div></div></blockquote></div><br></div></div></div>