Note that there are some explanatory texts on larger screens.

plurals
  1. POJava Netty 3.3.1.Final, DynamicChannelBuffer.java:75, infinite loop, a bug?
    primarykey
    data
    text
    <p>I am using Netty 3.3.1.Final for our needs of a custom server. Our execution is blocked in an infinite loop at: org.jboss.netty.buffer.DynamicChannelBuffer.ensureWritableBytes(DynamicChannelBuffer.java:75)</p> <p>Going into the code with the debuger will show an infinite loop starting with the initial values: minNewCapacity=2147483647 newCapacity=256<br> (Binary 1111111111111111111111111111111)<br/> (Binary 0000000000000000000000100000000)</p> <p>The reason is &lt;&lt;= operator will cause newCapacity to reach a maximum value of 1000000000000000000000000000000 and at the next step newCapacity will become 0 for ever.</p> <p>This part of the code lacks documentation so I cannot go deeper in my analyzis, but I would like to know if this is a known issue, and if I can use another version of netty?</p> <pre><code>@Override public void ensureWritableBytes(int minWritableBytes) { if (minWritableBytes &lt;= writableBytes()) { return; } int newCapacity; if (capacity() == 0) { newCapacity = 1; } else { newCapacity = capacity(); } int minNewCapacity = writerIndex() + minWritableBytes; //INFINITE LOOP HERE while (newCapacity &lt; minNewCapacity) { newCapacity &lt;&lt;= 1; } ChannelBuffer newBuffer = factory().getBuffer(order(), newCapacity); newBuffer.writeBytes(buffer, 0, writerIndex()); buffer = newBuffer; } </code></pre> <p>Thanks for your help,</p> <p>Renaud</p> <hr> <p>Added comment:</p> <p>This is method causing the minNewCapacity to be so high wich seems not good because it will lead to a huge memory buffer... org.jboss.netty.ReplayingDecoderBuffer.readableBytes(ReplayingDecoderBuffer.java:301)</p> <pre><code>public int readableBytes() { if (terminated) { return buffer.readableBytes(); } else { return Integer.MAX_VALUE - buffer.readerIndex(); } } </code></pre> <hr> <p>Added comment 2012/04/13</p> <p>I finally decided to not use the ReplayingDecoder because it leads to some very strange behaviour. In particular, it looks like it is not safe to use the mark() and reset() methods of the ChannelBuffer argument in the decode() method. When I tried to use buffer.slice() to wrap the ChannelBuffer in a "private" container, I got an exception, something like "Slice is not a replayable method...". It is not very complicated, thow to extend a FrameDecoder and re-implements the checkpoints logic...</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload