tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1545613 - in /tomcat/trunk/java/org/apache: catalina/connector/CoyoteAdapter.java coyote/Request.java
Date Tue, 26 Nov 2013 11:06:04 GMT
Author: markt
Date: Tue Nov 26 11:06:03 2013
New Revision: 1545613

URL: http://svn.apache.org/r1545613
Log:
Ensure that onAllDataRead() event is always fired once (and once only) after the request body
has been read

Modified:
    tomcat/trunk/java/org/apache/catalina/connector/CoyoteAdapter.java
    tomcat/trunk/java/org/apache/coyote/Request.java

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=1545613&r1=1545612&r2=1545613&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/connector/CoyoteAdapter.java (original)
+++ tomcat/trunk/java/org/apache/catalina/connector/CoyoteAdapter.java Tue Nov 26 11:06:03
2013
@@ -364,6 +364,9 @@ public class CoyoteAdapter implements Ad
                     try {
                         Thread.currentThread().setContextClassLoader(newCL);
                         res.onWritePossible();
+                        if (request.isFinished() && req.sendAllDataReadEvent()) {
+                            req.getReadListener().onAllDataRead();
+                        }
                     } catch (Throwable t) {
                         ExceptionUtils.handleThrowable(t);
                         res.getWriteListener().onError(t);
@@ -381,7 +384,7 @@ public class CoyoteAdapter implements Ad
                     try {
                         Thread.currentThread().setContextClassLoader(newCL);
                         req.getReadListener().onDataAvailable();
-                        if (request.isFinished()) {
+                        if (request.isFinished() && req.sendAllDataReadEvent()) {
                             req.getReadListener().onAllDataRead();
                         }
                     } catch (Throwable t) {
@@ -548,7 +551,9 @@ public class CoyoteAdapter implements Ad
                             request.getContext().getLoader().getClassLoader();
                     try {
                         Thread.currentThread().setContextClassLoader(newCL);
-                        req.getReadListener().onAllDataRead();
+                        if (req.sendAllDataReadEvent()) {
+                            req.getReadListener().onAllDataRead();
+                        }
                     } finally {
                         Thread.currentThread().setContextClassLoader(oldCL);
                     }

Modified: tomcat/trunk/java/org/apache/coyote/Request.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/Request.java?rev=1545613&r1=1545612&r2=1545613&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/Request.java (original)
+++ tomcat/trunk/java/org/apache/coyote/Request.java Tue Nov 26 11:06:03 2013
@@ -167,9 +167,15 @@ public final class Request {
         this.listener = listener;
     }
 
-    // ------------------------------------------------------------- Properties
+    private AtomicBoolean allDataReadEventSent = new AtomicBoolean(false);
+
+    public boolean sendAllDataReadEvent() {
+        return allDataReadEventSent.compareAndSet(false, true);
+    }
 
 
+    // ------------------------------------------------------------- Properties
+
     /**
      * Get the instance id (or JVM route). Currently Ajp is sending it with each
      * request. In future this should be fixed, and sent only once ( or
@@ -545,6 +551,7 @@ public final class Request {
         attributes.clear();
 
         listener = null;
+        allDataReadEventSent.set(false);
 
         startTime = -1;
     }



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


Mime
View raw message