connector.getContainer().getPipeline().getFirst().invoke(request, response);
if (request.isComet()) {
- if (!response.isClosed()) {
+ if (!response.isClosed() && !response.isError()) {
comet = true;
res.action(ActionCode.ACTION_COMET_BEGIN, null);
} else {
// Create and initialize a filter chain object
ApplicationFilterChain filterChain = null;
- if (!Globals.IS_SECURITY_ENABLED && (request instanceof Request)) {
+ if (request instanceof Request) {
Request req = (Request) request;
- filterChain = (ApplicationFilterChain) req.getFilterChain();
- if (filterChain == null) {
+ if (Globals.IS_SECURITY_ENABLED) {
+ // Security: Do not recycle
filterChain = new ApplicationFilterChain();
- req.setFilterChain(filterChain);
+ } else {
+ filterChain = (ApplicationFilterChain) req.getFilterChain();
+ if (filterChain == null) {
+ filterChain = new ApplicationFilterChain();
+ req.setFilterChain(filterChain);
+ }
}
comet = req.isComet();
} else {
- // Security: Do not recycle
+ // Request dispatcher in use
filterChain = new ApplicationFilterChain();
}
}
// Identify if the request is Comet related now that the servlet has been allocated
+ boolean comet = false;
if (servlet instanceof CometProcessor
&& request.getAttribute("org.apache.tomcat.comet.support") == Boolean.TRUE) {
- request.setComet(true);
+ comet = true;
}
// Acknowlege the request
if (context.getSwallowOutput()) {
try {
SystemLogHandler.startCapture();
- if (request.isComet()) {
+ if (comet) {
filterChain.doFilterEvent(request.getEvent());
+ request.setComet(true);
} else {
filterChain.doFilter(request.getRequest(),
response.getResponse());
}
}
} else {
- if (request.isComet()) {
+ if (comet) {
filterChain.doFilterEvent(request.getEvent());
+ request.setComet(true);
} else {
filterChain.doFilter
(request.getRequest(), response.getResponse());