Awesome, thanks!<br><br><div>Piotr</div><br><div class="gmail_quote">On Thu Dec 04 2014 at 3:06:07 AM Stuart Douglas &lt;<a href="mailto:sdouglas@redhat.com">sdouglas@redhat.com</a>&gt; wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I created a JIRA:<br>
<br>
<a href="https://issues.jboss.org/browse/UNDERTOW-349" target="_blank">https://issues.jboss.org/<u></u>browse/UNDERTOW-349</a><br>
<br>
Fix is upstream, will be in release of 1.1.2.Final and 1.2.0.Beta7.<br>
<br>
Stuart<br>
<br>
----- Original Message -----<br>
&gt; From: &quot;Piotr Betkier&quot; &lt;<a href="mailto:pbetkier@gmail.com" target="_blank">pbetkier@gmail.com</a>&gt;<br>
&gt; To: <a href="mailto:undertow-dev@lists.jboss.org" target="_blank">undertow-dev@lists.jboss.org</a><br>
&gt; Sent: Thursday, 4 December, 2014 9:12:25 AM<br>
&gt; Subject: [undertow-dev] Unexpected RequestLimitingHandler behavior after      queue gets full<br>
&gt;<br>
&gt; Hello,<br>
&gt;<br>
&gt; I wanted to introduce a constraint on the number of requests my server tries<br>
&gt; to handle at a time and played around with RequestLimitingHandler a little<br>
&gt; bit. However, I observed unexpected behavior once RequestLimit&#39;s queue gets<br>
&gt; full.<br>
&gt;<br>
&gt; I&#39;ve created a RequestLimitingHandler with both maximumConcurrentRequests and<br>
&gt; queueSize set to 1 and nextHandler that responds after a 3 second sleep.<br>
&gt; This is what I observed:<br>
&gt;<br>
&gt; When I sent 2 concurrent requests with a curl, I got the first response after<br>
&gt; 3 seconds and the second one after 6 - just as expected, the second request<br>
&gt; got queued.<br>
&gt;<br>
&gt; When I sent 3 concurrent requests, I got two correct responses and one 513 -<br>
&gt; just as expected, my third request couldn&#39;t fit into the queue so a failure<br>
&gt; handler got called.<br>
&gt;<br>
&gt; Now it got tricky - this made RequestLimit enter an invalid state, where its<br>
&gt; &quot;state&quot; field got decremented below the value that represents 0 current<br>
&gt; requests. Now &quot;state &amp; MASK_CURRENT&quot; gives 2147483647 instead of 0, so the<br>
&gt; next time I make a single request, RequestLimit thinks there are 2147483647<br>
&gt; requests in the system currently and queues my request instead of handling<br>
&gt; it. Then I make yet another request and now the queue is full, so 513 error<br>
&gt; is generated instantly which in turn makes RequestLimit poll my first<br>
&gt; pending request from the queue and dispatch it for handling. RequestLimit<br>
&gt; got corrupted and is unusable from now on.<br>
&gt;<br>
&gt; I hope I explained my observations clearly. Is there something wrong in my<br>
&gt; setup, my understanding of Undertow or it&#39;s a bug? This is my code snippet,<br>
&gt; tested with undertow 1.1.0.Final and 1.2.0.Beta5:<br>
&gt;<br>
&gt; import io.undertow.Undertow;<br>
&gt; import io.undertow.server.<u></u>HttpHandler;<br>
&gt; import io.undertow.server.<u></u>HttpServerExchange;<br>
&gt; import io.undertow.server.handlers.<u></u>RequestLimitingHandler;<br>
&gt; import io.undertow.util.Headers;<br>
&gt;<br>
&gt; public class Main {<br>
&gt;<br>
&gt; public static void main(String[] args) {<br>
&gt; Undertow server = Undertow.builder()<br>
&gt; .addHttpListener(8080, &quot;localhost&quot;)<br>
&gt; .setHandler(new RequestLimitingHandler(1, 1, handler()))<br>
&gt; .build();<br>
&gt;<br>
&gt; server.start();<br>
&gt; }<br>
&gt;<br>
&gt; private static HttpHandler handler() {<br>
&gt; return new HttpHandler() {<br>
&gt; @Override<br>
&gt; public void handleRequest(final HttpServerExchange exchange) throws Exception<br>
&gt; {<br>
&gt; Thread.sleep(3000);<br>
&gt; exchange.getResponseHeaders().<u></u>put(Headers.CONTENT_TYPE, &quot;text/plain&quot;);<br>
&gt; exchange.getResponseSender().<u></u>send(&quot;Hello World&quot;);<br>
&gt; }<br>
&gt; };<br>
&gt; }<br>
&gt;<br>
&gt; }<br>
&gt;<br>
&gt;<br>
&gt; Cheers,<br>
&gt; Piotr<br>
&gt;<br>
&gt;<br>
&gt; ______________________________<u></u>_________________<br>
&gt; undertow-dev mailing list<br>
&gt; <a href="mailto:undertow-dev@lists.jboss.org" target="_blank">undertow-dev@lists.jboss.org</a><br>
&gt; <a href="https://lists.jboss.org/mailman/listinfo/undertow-dev" target="_blank">https://lists.jboss.org/<u></u>mailman/listinfo/undertow-dev</a><br>
</blockquote></div>