You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by re...@apache.org on 2014/03/14 17:11:40 UTC

svn commit: r1577598 - /tomcat/trunk/java/org/apache/tomcat/util/net/SecureNio2Channel.java

Author: remm
Date: Fri Mar 14 16:11:40 2014
New Revision: 1577598

URL: http://svn.apache.org/r1577598
Log:
Make sure the byte buffer passed as a parameter is used in all read/write operations (come code is from the NIO1 which forces using the main read/write buffers).

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=1577598&r1=1577597&r2=1577598&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/net/SecureNio2Channel.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/net/SecureNio2Channel.java Fri Mar 14 16:11:40 2014
@@ -452,6 +452,10 @@ public class SecureNio2Channel extends N
     }
 
     private class FutureRead implements Future<Integer> {
+        private ByteBuffer dst;
+        public FutureRead(ByteBuffer dst) {
+            this.dst = dst;
+        }
         @Override
         public boolean cancel(boolean mayInterruptIfRunning) {
             return false;
@@ -490,7 +494,7 @@ public class SecureNio2Channel extends N
                 netInBuffer.flip();
                 //unwrap the data
                 try {
-                    unwrap = sslEngine.unwrap(netInBuffer, bufHandler.getReadBuffer());
+                    unwrap = sslEngine.unwrap(netInBuffer, dst);
                 } catch (SSLException e) {
                     throw new ExecutionException(e);
                 }
@@ -522,7 +526,8 @@ public class SecureNio2Channel extends N
 
     private class FutureNetRead extends FutureRead {
         private Future<Integer> integer;
-        protected FutureNetRead() {
+        protected FutureNetRead(ByteBuffer dst) {
+            super(dst);
             this.integer = sc.read(netInBuffer);
         }
         @Override
@@ -564,22 +569,24 @@ public class SecureNio2Channel extends N
         if (!handshakeComplete)
             throw new IllegalStateException("Handshake incomplete, you must complete handshake before reading data.");
         if (netInBuffer.position() > 0) {
-            return new FutureRead();
+            return new FutureRead(dst);
         } else {
-            return new FutureNetRead();
+            return new FutureNetRead(dst);
         }
     }
 
     private class FutureWrite implements Future<Integer> {
+        private ByteBuffer src;
         private Future<Integer> integer = null;
         private int written = 0;
         private Throwable t = null;
-        protected FutureWrite() {
+        protected FutureWrite(ByteBuffer src) {
             //are we closing or closed?
             if (closing || closed) {
                 t = new IOException("Channel is in closing state.");
                 return;
             }
+            this.src = src;
             wrap();
         }
         @Override
@@ -626,7 +633,7 @@ public class SecureNio2Channel extends N
             //The data buffer should be empty, we can reuse the entire buffer.
             netOutBuffer.clear();
             try {
-                SSLEngineResult result = sslEngine.wrap(bufHandler.getWriteBuffer(), netOutBuffer);
+                SSLEngineResult result = sslEngine.wrap(src, netOutBuffer);
                 written = result.bytesConsumed();
                 netOutBuffer.flip();
                 if (result.getStatus() == Status.OK) {
@@ -650,7 +657,7 @@ public class SecureNio2Channel extends N
      */
     @Override
     public Future<Integer> write(ByteBuffer src) {
-        return new FutureWrite();
+        return new FutureWrite(src);
     }
 
     private class ReadCompletionHandler<A> implements CompletionHandler<Integer, A> {



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