You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2023/08/09 19:20:08 UTC
[tomcat] 02/03: Refactor to enforce 1-2-1 mapping for request and InputBuffer
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
commit 32b1181b758161847a01cfa6bc10bf1d0c221d7c
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Wed Aug 9 20:07:31 2023 +0100
Refactor to enforce 1-2-1 mapping for request and InputBuffer
---
.../org/apache/catalina/connector/InputBuffer.java | 28 +++++++---------------
java/org/apache/catalina/connector/Request.java | 9 ++++---
2 files changed, 12 insertions(+), 25 deletions(-)
diff --git a/java/org/apache/catalina/connector/InputBuffer.java b/java/org/apache/catalina/connector/InputBuffer.java
index 58c3f8e103..f6160311d4 100644
--- a/java/org/apache/catalina/connector/InputBuffer.java
+++ b/java/org/apache/catalina/connector/InputBuffer.java
@@ -102,7 +102,7 @@ public class InputBuffer extends Reader implements ByteChunk.ByteInputChannel, A
/**
* Associated Coyote request.
*/
- private Request coyoteRequest;
+ private final Request coyoteRequest;
/**
@@ -128,21 +128,21 @@ public class InputBuffer extends Reader implements ByteChunk.ByteInputChannel, A
/**
* Default constructor. Allocate the buffer with the default buffer size.
+ *
+ * @param coyoteRequest The associated Coyote request
*/
- public InputBuffer() {
-
- this(DEFAULT_BUFFER_SIZE);
-
+ public InputBuffer(org.apache.coyote.Request coyoteRequest) {
+ this(DEFAULT_BUFFER_SIZE, coyoteRequest);
}
/**
* Alternate constructor which allows specifying the initial buffer size.
*
- * @param size Buffer size to use
+ * @param size Buffer size to use
+ * @param coyoteRequest The associated Coyote request
*/
- public InputBuffer(int size) {
-
+ public InputBuffer(int size, org.apache.coyote.Request coyoteRequest) {
this.size = size;
bb = ByteBuffer.allocate(size);
clear(bb);
@@ -150,18 +150,6 @@ public class InputBuffer extends Reader implements ByteChunk.ByteInputChannel, A
clear(cb);
readLimit = size;
- }
-
-
- // ------------------------------------------------------------- Properties
-
-
- /**
- * Associated Coyote request.
- *
- * @param coyoteRequest Associated Coyote request
- */
- public void setRequest(Request coyoteRequest) {
this.coyoteRequest = coyoteRequest;
}
diff --git a/java/org/apache/catalina/connector/Request.java b/java/org/apache/catalina/connector/Request.java
index a13eee3bb6..8ec5f187c0 100644
--- a/java/org/apache/catalina/connector/Request.java
+++ b/java/org/apache/catalina/connector/Request.java
@@ -146,13 +146,12 @@ public class Request implements HttpServletRequest {
public Request(Connector connector, org.apache.coyote.Request coyoteRequest) {
this.connector = connector;
this.coyoteRequest = coyoteRequest;
- inputBuffer.setRequest(coyoteRequest);
+ inputBuffer = new InputBuffer(coyoteRequest);
}
// ------------------------------------------------------------- Properties
-
/**
* Coyote request.
*/
@@ -228,19 +227,19 @@ public class Request implements HttpServletRequest {
/**
* The associated input buffer.
*/
- protected final InputBuffer inputBuffer = new InputBuffer();
+ protected final InputBuffer inputBuffer;
/**
* ServletInputStream.
*/
- protected CoyoteInputStream inputStream = new CoyoteInputStream(inputBuffer);
+ protected CoyoteInputStream inputStream;
/**
* Reader.
*/
- protected CoyoteReader reader = new CoyoteReader(inputBuffer);
+ protected CoyoteReader reader;
/**
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org