-
Bug
-
Resolution: Done
-
Major
-
8.0.0.Final, 8.1.0.Final
With asynchronous mode of servlets a long running process never times out.
In my tests I have a async servlet which calls starts a long running process. That process take longer then the configured timeout. But here never a timeout comes. The long running process can complete.
According to the spec, the servlet should run into a timeout and the AsyncListener#onTimeout method is called for registered listeners.
But this never happens in Wildfly 8.
Here is a test servlet
AsyncServlet.java
@WebServlet(urlPatterns = {"/AsyncServlet"}, asyncSupported = true) public class AsyncServlet extends HttpServlet { private static final long serialVersionUID = 1L; public AsyncServlet() { super(); } @Override protected void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { res.setContentType("text/html"); final AsyncContext ac; if (req.isAsyncStarted()) { ac = req.getAsyncContext(); } else { ac = req.startAsync(); } ac.setTimeout(5000); ac.addListener(new AsyncListener() { @Override public void onTimeout(AsyncEvent event) throws IOException { System.out.println("onTimeout"); } @Override public void onStartAsync(AsyncEvent event) throws IOException { System.out.println("onStartAsync"); } @Override public void onError(AsyncEvent event) throws IOException { System.out.println("onError"); } @Override public void onComplete(AsyncEvent event) throws IOException { // end of async processing -> end of response time System.out.println("onComplete"); } }); // this processor takes longer then the timeout. e.g. 20 sec ac.start(new Runnable() { @Override public void run() { try { Thread.sleep(20*1000); // working... ac.complete(); } catch (InterruptedException e) { e.printStackTrace(); } } }); // start async processing } }