https://issues.apache.org/bugzilla/show_bug.cgi?id=57157
Bug ID: 57157
Summary: out.setWriteListener in runnable of
AsyncContext.start(runnable) cause response failed
Product: Tomcat 8
Version: 8.0.14
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P2
Component: Catalina
Assignee: [email protected]
Reporter: [email protected]
Created attachment 32157
--> https://issues.apache.org/bugzilla/attachment.cgi?id=32157&action=edit
related java code files
stack trace:
28-Oct-2014 11:56:26.891 SEVERE [http-nio-8080-exec-5]
org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun
java.lang.NullPointerException
at
org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1538)
at
org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1523)
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at
org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:744)
related code:
TextReadListener
public synchronized void onAllDataRead() throws IOException {
logger.debug("onAllDataRead", new Exception("onAllDataRead"));
final String text = (buf != null ? buf.toString("UTF-8") : "");
logger.debug("onAllDataRead> text={}", text);
HttpServletRequest req = (HttpServletRequest) asyncCtx.getRequest();
logger.debug("onAllDataRead> uri={}, User-Agent={}, params={}",
req.getRequestURI(),
req.getHeader("User-Agent"), req.getParameterMap());
final ServletOutputStream out =
asyncCtx.getResponse().getOutputStream();
asyncCtx.start(new Runnable() {
@Override
public void run() {
try {
logger.debug("start sleep");
TimeUnit.SECONDS.sleep(1);
logger.debug("sleep finished, start writing");
WriteListener writeListener = new TextWriteListener(("test"
+ text).getBytes("UTF-8"), asyncCtx,
out);
out.setWriteListener(writeListener);
} catch (Throwable e) {
logger.error("impossible ex", e);
}
}
});
}
If I just invoke out.setWriteListener in onAllDataRead method (not in
asyncCtx.start), then that's ok.
Detailed java code is in attachment
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]