Are there any parallel issues with Integer.MAX_VALUE
<p>I have the following code:</p>

<pre><code>if (maxLength&gt;=0 &amp;&amp; (++totalLength &gt; maxLength))
    throw new IllegalStateException("Form too large");
</code></pre>

<p>in a loop where bytes are read from byte array input stream. The <code>maxLength</code> is set to <code>Integer.MAX_VALUE</code> so I think that the condition could never be true (and I'm not talking about the size of the byte array in input stream which I'm absolutely sure is not long enough). But I get the <code>IllegalStateException</code> thrown from that line!!! Now the real bummer is that when I put a breakpoint on that throw line, everything is ok. How the hell is this possible?</p>

<p><strong>EDIT</strong>:</p>

<ul>
<li>both variables are of type int</li>
<li>totalLength is a local variable, maxLength is a parameter</li>
<li>the debugger don't stop there AND the exception is not thrown at all, when there is a breakpoint on that throw line.</li>
<li>I actualy don't know why I'm suspecting parallelism, it's just because it's web application</li>
<li>I admit that using MAX_VALUE is very risky (in the next step I will try to decrease this limit), but I would expect some other execption than that in the success branch of if statement. And moreover that byte array used in input stream is really not long enough. This should be plainly impossible situation in JVM:-).</li>
<li><p>The code above is in jetty-util-7.1.5.v20100705.jar in the class UrlEncoded and I'm using it by calling</p>

<pre><code>byte[] decodedBytes;
byte[] encodedBytes;

// v pripade url encoded requestu je potreba pouze odriznout
// jmeno falesneho parametru nesouciho kodovany blok
encodedBytes = Arrays.copyOfRange(content, "encdata=".length(), content.length);
decodedBytes = decodeBytes(request, encodedBytes);

// priprav desifrovany text jako vstupni proud
decodedInputStream = new ByteArrayInputStream(decodedBytes);

// pokud je request url encoded je potreba jej manualne parsovat
// pro potreby funkci vracejicich parametry
UrlEncoded.decodeTo(decodedInputStream, parameters, request.getCharacterEncoding(), Integer.MAX_VALUE);
</code></pre></li>
</ul>
