[jboss-jira] [JBoss JIRA] (WFLY-3526) Servlet 3 - async-mode - onTimeout not triggered
Günther Grill (JIRA)
issues at jboss.org
Fri Jun 20 04:15:28 EDT 2014
[ https://issues.jboss.org/browse/WFLY-3526?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Günther Grill updated WFLY-3526:
--------------------------------
Description:
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. 15 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}
was:
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");
AsyncContext ac = null;
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. 15 sec
ac.start(new Runnable() {
@Override
public void run() {
try {
Thread.sleep(20*1000); // working...
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}); // start async processing
}
}
{code}
> Servlet 3 - async-mode - onTimeout not triggered
> ------------------------------------------------
>
> Key: WFLY-3526
> URL: https://issues.jboss.org/browse/WFLY-3526
> Project: WildFly
> Issue Type: Bug
> Security Level: Public(Everyone can see)
> Components: Server
> Affects Versions: 8.0.0.Final, 8.1.0.Final
> Reporter: Günther Grill
> Assignee: Jason Greene
> Labels: async, asynchronous, servlet, timeout
>
> 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. 15 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.2.6#6264)
More information about the jboss-jira
mailing list