[jboss-jira] [JBoss JIRA] (WFLY-3526) Servlet 3 - async-mode - onTimeout not triggered
Günther Grill (JIRA)
issues at jboss.org
Fri Feb 13 06:58:49 EST 2015
[ https://issues.jboss.org/browse/WFLY-3526?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Günther Grill updated WFLY-3526:
--------------------------------
Fix Version/s: 8.2.0.Final
> Servlet 3 - async-mode - onTimeout not triggered
> ------------------------------------------------
>
> Key: WFLY-3526
> URL: https://issues.jboss.org/browse/WFLY-3526
> Project: WildFly
> Issue Type: Bug
> Components: Server
> Affects Versions: 8.0.0.Final, 8.1.0.Final
> Reporter: Günther Grill
> Assignee: Jason Greene
> Labels: async, asynchronous, servlet, timeout
> Fix For: 8.2.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
> {code:title=AsyncServlet.java|borderStyle=solid}
> @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
> }
> }
> {code}
--
This message was sent by Atlassian JIRA
(v6.3.11#6341)
More information about the jboss-jira
mailing list