This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 11.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 607dfe52c8b7e1f03236ae5a0f7baeb3389d377a
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Thu Jan 9 14:01:18 2025 +0000

    Refactor so the buffered data is used directly rather than copied
    
    This also aligns with other uses of o.a.catalina.connector.InputBuffer
    where a pre-populated buffer replaces InputBuffer#bb rather than the
    data being copied into the existing InputBuffer#bb
---
 .../apache/coyote/http11/filters/SavedRequestInputFilter.java    | 9 ++++-----
 webapps/docs/changelog.xml                                       | 4 ++++
 2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/java/org/apache/coyote/http11/filters/SavedRequestInputFilter.java 
b/java/org/apache/coyote/http11/filters/SavedRequestInputFilter.java
index 9bead7331e..84b6ae8f7b 100644
--- a/java/org/apache/coyote/http11/filters/SavedRequestInputFilter.java
+++ b/java/org/apache/coyote/http11/filters/SavedRequestInputFilter.java
@@ -49,11 +49,10 @@ public class SavedRequestInputFilter implements InputFilter 
{
             return -1;
         }
 
-        ByteBuffer byteBuffer = handler.getByteBuffer();
-        byteBuffer.position(byteBuffer.limit()).limit(byteBuffer.capacity());
-        input.subtract(byteBuffer);
-
-        return byteBuffer.remaining();
+        int len = input.getLength();
+        handler.setByteBuffer(ByteBuffer.wrap(input.getBytes(), 
input.getStart(), len));
+        input.setStart(input.getEnd());
+        return len;
     }
 
     /**
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 4ed3acdc65..3d12fb0c8e 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -144,6 +144,10 @@
         processing poller events for the NIO Connector as this may occur in
         normal usage. (markt)
       </fix>
+      <scode>
+        Refactor the <code>SavedRequestInputFilter</code> so the buffered data
+        is used directly rather than copied. (markt)
+      </scode>
     </changelog>
   </subsection>
 </section>


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

Reply via email to