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

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


The following commit(s) were added to refs/heads/main by this push:
     new 31e02d0062 Refactor to enforce 1-2-1 mapping for OutputBuffer and 
Coyote response
31e02d0062 is described below

commit 31e02d00625cbb7a4c575442322533f5139acf6c
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Wed Aug 9 19:44:27 2023 +0100

    Refactor to enforce 1-2-1 mapping for OutputBuffer and Coyote response
---
 java/org/apache/catalina/connector/OutputBuffer.java | 18 +++++-------------
 java/org/apache/catalina/connector/Response.java     |  3 +--
 2 files changed, 6 insertions(+), 15 deletions(-)

diff --git a/java/org/apache/catalina/connector/OutputBuffer.java 
b/java/org/apache/catalina/connector/OutputBuffer.java
index 096055bfae..a0d85c4f64 100644
--- a/java/org/apache/catalina/connector/OutputBuffer.java
+++ b/java/org/apache/catalina/connector/OutputBuffer.java
@@ -112,7 +112,7 @@ public class OutputBuffer extends Writer {
     /**
      * Associated Coyote response.
      */
-    private Response coyoteResponse;
+    private final Response coyoteResponse;
 
 
     /**
@@ -126,29 +126,21 @@ public class OutputBuffer extends Writer {
     /**
      * Create the buffer with the specified initial size.
      *
-     * @param size Buffer size to use
+     * @param size           Buffer size to use
+     * @param coyoteResponse The associated Coyote response
      */
-    public OutputBuffer(int size) {
+    public OutputBuffer(int size, Response coyoteResponse) {
         defaultBufferSize = size;
         bb = ByteBuffer.allocate(size);
         clear(bb);
         cb = CharBuffer.allocate(size);
         clear(cb);
+        this.coyoteResponse = coyoteResponse;
     }
 
 
     // ------------------------------------------------------------- Properties
 
-    /**
-     * Associated Coyote response.
-     *
-     * @param coyoteResponse Associated Coyote response
-     */
-    public void setResponse(Response coyoteResponse) {
-        this.coyoteResponse = coyoteResponse;
-    }
-
-
     /**
      * Is the response output suspended ?
      *
diff --git a/java/org/apache/catalina/connector/Response.java 
b/java/org/apache/catalina/connector/Response.java
index db77a6971b..4de1e86b40 100644
--- a/java/org/apache/catalina/connector/Response.java
+++ b/java/org/apache/catalina/connector/Response.java
@@ -155,8 +155,7 @@ public class Response implements HttpServletResponse {
 
     public Response(org.apache.coyote.Response coyoteResponse, int 
outputBufferSize) {
         this.coyoteResponse = coyoteResponse;
-        outputBuffer = new OutputBuffer(outputBufferSize);
-        outputBuffer.setResponse(coyoteResponse);
+        outputBuffer = new OutputBuffer(outputBufferSize, coyoteResponse);
     }
 
 


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

Reply via email to