Skip to content

Commit

Permalink
Issue #4323 Ensure QoSFilter handles IllegalStateException (#4372)
Browse files Browse the repository at this point in the history
Signed-off-by: Jan Bartel <[email protected]>
  • Loading branch information
janbartel authored Dec 3, 2019
1 parent 85cda88 commit db9ad2f
Showing 1 changed file with 15 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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();
}
}
}
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit db9ad2f

Please sign in to comment.