svn commit: r1824078 - /tomcat/trunk/java/org/apache/coyote/http2/Http2AsyncParser.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r1824078 - /tomcat/trunk/java/org/apache/coyote/http2/Http2AsyncParser.java

Rémy Maucherat
Author: remm
Date: Mon Feb 12 21:29:51 2018
New Revision: 1824078

URL: http://svn.apache.org/viewvc?rev=1824078&view=rev
Log:
Finish the todo: reuse the two buffers using a clear.

Modified:
    tomcat/trunk/java/org/apache/coyote/http2/Http2AsyncParser.java

Modified: tomcat/trunk/java/org/apache/coyote/http2/Http2AsyncParser.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http2/Http2AsyncParser.java?rev=1824078&r1=1824077&r2=1824078&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http2/Http2AsyncParser.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http2/Http2AsyncParser.java Mon Feb 12 21:29:51 2018
@@ -33,12 +33,16 @@ class Http2AsyncParser extends Http2Pars
     private final SocketWrapperBase<?> socketWrapper;
     private final Http2AsyncUpgradeHandler upgradeHandler;
     private Throwable error = null;
+    private final ByteBuffer header;
+    private final ByteBuffer framePaylod;
 
     Http2AsyncParser(String connectionId, Input input, Output output, SocketWrapperBase<?> socketWrapper, Http2AsyncUpgradeHandler upgradeHandler) {
         super(connectionId, input, output);
         this.socketWrapper = socketWrapper;
         socketWrapper.getSocketBufferHandler().expand(input.getMaxFrameSize());
         this.upgradeHandler = upgradeHandler;
+        header = ByteBuffer.allocate(9);
+        framePaylod = ByteBuffer.allocate(input.getMaxFrameSize());
     }
 
 
@@ -49,9 +53,8 @@ class Http2AsyncParser extends Http2Pars
             return super.readFrame(block, expected);
         }
         handleAsyncException();
-        // TODO: examine if it could be possible to reuse byte buffers
-        ByteBuffer header = ByteBuffer.allocate(9);
-        ByteBuffer framePaylod = ByteBuffer.allocate(input.getMaxFrameSize());
+        header.clear();
+        framePaylod.clear();
         FrameCompletionHandler handler = new FrameCompletionHandler(expected, header, framePaylod);
         FrameCompletionCheck check = new FrameCompletionCheck(handler);
         CompletionState state =



---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]