Author: markt
Date: Fri Dec 18 11:17:34 2015
New Revision: 1720752

URL: http://svn.apache.org/viewvc?rev=1720752&view=rev
Log:
Fix https://bz.apache.org/bugzilla/show_bug.cgi?id=58702
Ensure an access log entry is generated if the client aborts the connection.

Modified:
    tomcat/trunk/java/org/apache/catalina/connector/CoyoteAdapter.java
    tomcat/trunk/webapps/docs/changelog.xml

Modified: tomcat/trunk/java/org/apache/catalina/connector/CoyoteAdapter.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/connector/CoyoteAdapter.java?rev=1720752&r1=1720751&r2=1720752&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/connector/CoyoteAdapter.java 
(original)
+++ tomcat/trunk/java/org/apache/catalina/connector/CoyoteAdapter.java Fri Dec 
18 11:17:34 2015
@@ -246,15 +246,6 @@ public class CoyoteAdapter implements Ad
             if (!request.isAsync()) {
                 request.finishRequest();
                 response.finishResponse();
-                if (request.getMappingData().context != null) {
-                    request.getMappingData().context.logAccess(
-                            request, response,
-                            System.currentTimeMillis() - req.getStartTime(),
-                            false);
-                } else {
-                    // Should normally not happen
-                    log(req, res, System.currentTimeMillis() - 
req.getStartTime());
-                }
             }
 
             // Check to see if the processor is in an error state. If it is,
@@ -274,12 +265,21 @@ public class CoyoteAdapter implements Ad
         } finally {
             if (!success) {
                 res.setStatus(500);
+            }
+
+            // Access logging
+            if (!success || !request.isAsync()) {
                 long time = 0;
                 if (req.getStartTime() != -1) {
                     time = System.currentTimeMillis() - req.getStartTime();
                 }
-                log(req, res, time);
+                if (request.getMappingData().context != null) {
+                    request.getMappingData().context.logAccess(request, 
response, time, false);
+                } else {
+                    log(req, res, time);
+                }
             }
+
             req.getRequestProcessor().setWorkerThreadName(null);
             // Recycle the wrapper request and response
             if (!success || !request.isAsync()) {
@@ -290,6 +290,7 @@ public class CoyoteAdapter implements Ad
         return success;
     }
 
+
     /**
      * Service method.
      */
@@ -328,13 +329,13 @@ public class CoyoteAdapter implements Ad
         }
 
         boolean async = false;
+        boolean postParseSuccess = false;
 
         try {
-
             // Parse and set Catalina and configuration specific
             // request parameters
             req.getRequestProcessor().setWorkerThreadName(THREAD_NAME.get());
-            boolean postParseSuccess = postParseRequest(req, request, res, 
response);
+            postParseSuccess = postParseRequest(req, request, res, response);
             if (postParseSuccess) {
                 //check valves if we support async
                 
request.setAsyncSupported(connector.getService().getContainer().getPipeline().isAsyncSupported());
@@ -361,6 +362,13 @@ public class CoyoteAdapter implements Ad
             } else {
                 request.finishRequest();
                 response.finishResponse();
+            }
+
+        } catch (IOException e) {
+            // Ignore
+        } finally {
+            // Access log
+            if (!async) {
                 if (postParseSuccess) {
                     // Log only if processing was invoked.
                     // If postParseRequest() failed, it has already logged it.
@@ -371,12 +379,10 @@ public class CoyoteAdapter implements Ad
                 }
             }
 
-        } catch (IOException e) {
-            // Ignore
-        } finally {
             req.getRequestProcessor().setWorkerThreadName(null);
             AtomicBoolean error = new AtomicBoolean(false);
             res.action(ActionCode.IS_ERROR, error);
+
             // Recycle the wrapper request and response
             if (!async || error.get()) {
                 request.recycle();

Modified: tomcat/trunk/webapps/docs/changelog.xml
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/changelog.xml?rev=1720752&r1=1720751&r2=1720752&view=diff
==============================================================================
--- tomcat/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/trunk/webapps/docs/changelog.xml Fri Dec 18 11:17:34 2015
@@ -143,6 +143,10 @@
         the failure of the web application. Includes a test case written by
          Derek Abdine. (markt)
       </fix>
+      <fix>
+        <bug>58702</bug>: Ensure an access log entry is generated if the client
+        aborts the connection. (markt)
+      </fix>
     </changelog>
   </subsection>
   <subsection name="Coyote">



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to