diff --git a/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/QoSFilter.java b/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/QoSFilter.java index 17fe000e5c36..40a4668b27d0 100644 --- a/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/QoSFilter.java +++ b/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/QoSFilter.java @@ -216,6 +216,8 @@ public void doFilter(ServletRequest request, ServletResponse response, FilterCha { if (accepted) { + _passes.release(); + for (int p = _queues.length - 1; p >= 0; --p) { AsyncContext asyncContext = _queues[p].poll(); @@ -225,13 +227,20 @@ public void doFilter(ServletRequest request, ServletResponse response, FilterCha Boolean suspended = (Boolean)candidate.getAttribute(_suspended); if (Boolean.TRUE.equals(suspended)) { - candidate.setAttribute(_resumed, Boolean.TRUE); - asyncContext.dispatch(); - break; + try + { + candidate.setAttribute(_resumed, Boolean.TRUE); + asyncContext.dispatch(); + break; + } + catch (IllegalStateException x) + { + LOG.warn(x); + continue; + } } } } - _passes.release(); } } } @@ -368,7 +377,8 @@ public void onTimeout(AsyncEvent event) throws IOException // redispatched again at the end of the filtering. AsyncContext asyncContext = event.getAsyncContext(); _queues[priority].remove(asyncContext); - asyncContext.dispatch(); + ((HttpServletResponse)event.getSuppliedResponse()).sendError(HttpServletResponse.SC_SERVICE_UNAVAILABLE); + asyncContext.complete(); } @Override