Author: fhanik
Date: Tue Mar  1 19:58:55 2011
New Revision: 1076004

URL: http://svn.apache.org/viewvc?rev=1076004&view=rev
Log:
Correctly determine if a buffer has data or not

Modified:
    tomcat/trunk/java/org/apache/tomcat/util/net/SecureNioChannel.java

Modified: tomcat/trunk/java/org/apache/tomcat/util/net/SecureNioChannel.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/net/SecureNioChannel.java?rev=1076004&r1=1076003&r2=1076004&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/net/SecureNioChannel.java 
(original)
+++ tomcat/trunk/java/org/apache/tomcat/util/net/SecureNioChannel.java Tue Mar  
1 19:58:55 2011
@@ -220,10 +220,10 @@ public class SecureNioChannel extends Ni
      */
     public void rehandshake(long timeout) throws IOException {
         //validate the network buffers are empty
-        if (netInBuffer.position() > 0) throw new IOException("Network input 
buffer still contains data. Handshake will fail.");
-        if (netOutBuffer.position() > 0) throw new IOException("Network output 
buffer still contains data. Handshake will fail.");
-        if (getBufHandler().getReadBuffer().position()>0) throw new 
IOException("Aplication input buffer still contains data. Data would have been 
lost.");
-        if (getBufHandler().getWriteBuffer().position()>0) throw new 
IOException("Aplication output buffer still contains data. Data would have been 
lost.");
+        if (netInBuffer.position() > 0 && 
netInBuffer.position()<netInBuffer.limit()) throw new IOException("Network 
input buffer still contains data. Handshake will fail.");
+        if (netOutBuffer.position() > 0 && 
netOutBuffer.position()<netOutBuffer.limit()) throw new IOException("Network 
output buffer still contains data. Handshake will fail.");
+        if (getBufHandler().getReadBuffer().position()>0 && 
getBufHandler().getReadBuffer().position()<getBufHandler().getReadBuffer().limit())
 throw new IOException("Aplication input buffer still contains data. Data would 
have been lost.");
+        if (getBufHandler().getWriteBuffer().position()>0 && 
getBufHandler().getWriteBuffer().position()<getBufHandler().getWriteBuffer().limit())
 throw new IOException("Aplication output buffer still contains data. Data 
would have been lost.");
         reset();
         boolean isReadable = true;
         boolean isWriteable = true;



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

Reply via email to