Author: markt
Date: Fri Feb 27 15:01:25 2015
New Revision: 1662707

URL: http://svn.apache.org/r1662707
Log:
Writes are not guaranteed to empty the buffer

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

Modified: tomcat/trunk/java/org/apache/tomcat/util/net/SecureNio2Channel.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/net/SecureNio2Channel.java?rev=1662707&r1=1662706&r2=1662707&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/net/SecureNio2Channel.java 
(original)
+++ tomcat/trunk/java/org/apache/tomcat/util/net/SecureNio2Channel.java Fri Feb 
27 15:01:25 2015
@@ -671,17 +671,18 @@ public class SecureNio2Channel extends N
             }
         }
         protected void wrap() {
-            //The data buffer should be empty, we can reuse the entire buffer.
-            netOutBuffer.clear();
             try {
-                SSLEngineResult result = sslEngine.wrap(src, netOutBuffer);
-                written = result.bytesConsumed();
-                netOutBuffer.flip();
-                if (result.getStatus() == Status.OK) {
-                    if (result.getHandshakeStatus() == 
HandshakeStatus.NEED_TASK)
-                        tasks();
-                } else {
-                    t = new 
IOException(sm.getString("channel.nio.ssl.wrapFail", result.getStatus()));
+                if (!netOutBuffer.hasRemaining()) {
+                    netOutBuffer.clear();
+                    SSLEngineResult result = sslEngine.wrap(src, netOutBuffer);
+                    written = result.bytesConsumed();
+                    netOutBuffer.flip();
+                    if (result.getStatus() == Status.OK) {
+                        if (result.getHandshakeStatus() == 
HandshakeStatus.NEED_TASK)
+                            tasks();
+                    } else {
+                        t = new 
IOException(sm.getString("channel.nio.ssl.wrapFail", result.getStatus()));
+                    }
                 }
                 integer = sc.write(netOutBuffer);
             } catch (SSLException e) {



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

Reply via email to