tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1519798 - in /tomcat/trunk/java/org/apache/catalina/connector: CoyoteInputStream.java CoyoteOutputStream.java
Date Tue, 03 Sep 2013 19:04:00 GMT
Author: markt
Date: Tue Sep  3 19:04:00 2013
New Revision: 1519798

URL: http://svn.apache.org/r1519798
Log:
Fix failing unit test and Gump with BIO
Make the test for having to call isReady() before any non-blocking read or write stricter.
Previously, an app would get away with this if isReady() would have returned true if it had
been called.

Modified:
    tomcat/trunk/java/org/apache/catalina/connector/CoyoteInputStream.java
    tomcat/trunk/java/org/apache/catalina/connector/CoyoteOutputStream.java

Modified: tomcat/trunk/java/org/apache/catalina/connector/CoyoteInputStream.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/connector/CoyoteInputStream.java?rev=1519798&r1=1519797&r2=1519798&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/connector/CoyoteInputStream.java (original)
+++ tomcat/trunk/java/org/apache/catalina/connector/CoyoteInputStream.java Tue Sep  3 19:04:00
2013
@@ -40,6 +40,7 @@ public class CoyoteInputStream extends S
 
 
     protected InputBuffer ib;
+    private volatile Boolean ready = null;
 
 
     protected CoyoteInputStream(InputBuffer ib) {
@@ -240,7 +241,8 @@ public class CoyoteInputStream extends S
 
     @Override
     public boolean isReady() {
-        return ib.isReady();
+        ready = Boolean.valueOf(ib.isReady());
+        return ready.booleanValue();
     }
 
 
@@ -251,9 +253,10 @@ public class CoyoteInputStream extends S
 
 
     private void checkNonBlockingRead() {
-        if (ib.isBlocking() && !ib.isReady()) {
+        if (ib.isBlocking() && (ready == null || !ready.booleanValue())) {
             throw new IllegalStateException(
                     sm.getString("coyoteInputStream.nbNotready"));
         }
+        ready = null;
     }
 }

Modified: tomcat/trunk/java/org/apache/catalina/connector/CoyoteOutputStream.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/connector/CoyoteOutputStream.java?rev=1519798&r1=1519797&r2=1519798&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/connector/CoyoteOutputStream.java (original)
+++ tomcat/trunk/java/org/apache/catalina/connector/CoyoteOutputStream.java Tue Sep  3 19:04:00
2013
@@ -35,12 +35,8 @@ public class CoyoteOutputStream extends 
             StringManager.getManager(Constants.Package);
 
 
-    // ----------------------------------------------------- Instance Variables
-
     protected OutputBuffer ob;
-
-
-    // ----------------------------------------------------------- Constructors
+    private volatile Boolean ready = null;
 
 
     protected CoyoteOutputStream(OutputBuffer ob) {
@@ -48,22 +44,15 @@ public class CoyoteOutputStream extends 
     }
 
 
-    // --------------------------------------------------------- Public Methods
-
-
     /**
      * Prevent cloning the facade.
      */
     @Override
-    protected Object clone()
-        throws CloneNotSupportedException {
+    protected Object clone() throws CloneNotSupportedException {
         throw new CloneNotSupportedException();
     }
 
 
-    // -------------------------------------------------------- Package Methods
-
-
     /**
      * Clear facade.
      */
@@ -72,9 +61,6 @@ public class CoyoteOutputStream extends 
     }
 
 
-    // --------------------------------------------------- OutputStream Methods
-
-
     @Override
     public void write(int i) throws IOException {
         boolean nonBlocking = checkNonBlockingWrite();
@@ -124,10 +110,11 @@ public class CoyoteOutputStream extends 
      */
     private boolean checkNonBlockingWrite() {
         boolean nonBlocking = !ob.isBlocking();
-        if (nonBlocking && !ob.isReady()) {
+        if (nonBlocking && (ready == null || !ready.booleanValue())) {
             throw new IllegalStateException(
                     sm.getString("coyoteOutputStream.nbNotready"));
         }
+        ready = null;
         return nonBlocking;
     }
 
@@ -153,7 +140,8 @@ public class CoyoteOutputStream extends 
 
     @Override
     public boolean isReady() {
-        return ob.isReady();
+        ready = Boolean.valueOf(ob.isReady());
+        return ready.booleanValue();
     }
 
 



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


Mime
View raw message