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