- Adjustments to error processing with Comet during the begin event (exceptions not...
authorremm <remm@13f79535-47bb-0310-9956-ffa450edef68>
Fri, 30 Mar 2007 14:38:02 +0000 (14:38 +0000)
committerremm <remm@13f79535-47bb-0310-9956-ffa450edef68>
Fri, 30 Mar 2007 14:38:02 +0000 (14:38 +0000)
- Fix a probable bug when security was enabled (Comet would most likely not work).

git-svn-id: https://svn.apache.org/repos/asf/tomcat/tc6.0.x/trunk@524103 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/catalina/connector/CoyoteAdapter.java
java/org/apache/catalina/core/ApplicationFilterFactory.java
java/org/apache/catalina/core/StandardWrapperValve.java

index 7054fc6..810b755 100644 (file)
@@ -216,7 +216,7 @@ public class CoyoteAdapter
                 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 {
index c3cdd4f..212a173 100644 (file)
@@ -121,16 +121,21 @@ public final class ApplicationFilterFactory {
         
         // 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();
         }
 
index 887b1e6..c992de0 100644 (file)
@@ -159,9 +159,10 @@ final class StandardWrapperValve
         }
 
         // 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
@@ -209,8 +210,9 @@ final class StandardWrapperValve
                 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());
@@ -222,8 +224,9 @@ final class StandardWrapperValve
                         }
                     }
                 } else {
-                    if (request.isComet()) {
+                    if (comet) {
                         filterChain.doFilterEvent(request.getEvent());
+                        request.setComet(true);
                     } else {
                         filterChain.doFilter
                             (request.getRequest(), response.getResponse());