This is an automated email from the ASF dual-hosted git repository.
markt pushed a commit to branch 8.5.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/8.5.x by this push:
new 3dfc7aa5d8 Clean-up - no functional change
3dfc7aa5d8 is described below
commit 3dfc7aa5d897f6ae8ee8fc346b028033b2dcebb3
Author: Mark Thomas <[email protected]>
AuthorDate: Tue Nov 7 14:10:30 2023 +0000
Clean-up - no functional change
---
.../catalina/core/ApplicationHttpRequest.java | 63 ++++++----------------
.../apache/catalina/core/ApplicationRequest.java | 38 ++-----------
2 files changed, 19 insertions(+), 82 deletions(-)
diff --git a/java/org/apache/catalina/core/ApplicationHttpRequest.java
b/java/org/apache/catalina/core/ApplicationHttpRequest.java
index c45f895819..1f9d64dbbb 100644
--- a/java/org/apache/catalina/core/ApplicationHttpRequest.java
+++ b/java/org/apache/catalina/core/ApplicationHttpRequest.java
@@ -16,7 +16,6 @@
*/
package org.apache.catalina.core;
-
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.nio.charset.Charset;
@@ -51,7 +50,6 @@ import org.apache.tomcat.util.buf.MessageBytes;
import org.apache.tomcat.util.http.Parameters;
import org.apache.tomcat.util.res.StringManager;
-
/**
* Wrapper around a <code>javax.servlet.http.HttpServletRequest</code> that
transforms an application request object
* (which might be the original one passed to a servlet, or might be based on
the 2.3
@@ -83,29 +81,6 @@ class ApplicationHttpRequest extends
HttpServletRequestWrapper {
private static final int SPECIALS_FIRST_FORWARD_INDEX = 6;
- // ----------------------------------------------------------- Constructors
-
-
- /**
- * Construct a new wrapped request around the specified servlet request.
- *
- * @param request The servlet request being wrapped
- * @param context The target context for the wrapped request
- * @param crossContext {@code true} if the wrapped request will be a
cross-context request, otherwise {@code false}
- */
- ApplicationHttpRequest(HttpServletRequest request, Context context,
boolean crossContext) {
-
- super(request);
- this.context = context;
- this.crossContext = crossContext;
- setRequest(request);
-
- }
-
-
- // ----------------------------------------------------- Instance Variables
-
-
/**
* The context for this request.
*/
@@ -196,6 +171,21 @@ class ApplicationHttpRequest extends
HttpServletRequestWrapper {
protected final Object[] specialAttributes = new Object[specials.length];
+ /**
+ * Construct a new wrapped request around the specified servlet request.
+ *
+ * @param request The servlet request being wrapped
+ * @param context The target context for the wrapped request
+ * @param crossContext {@code true} if the wrapped request will be a
cross-context request, otherwise {@code false}
+ */
+ ApplicationHttpRequest(HttpServletRequest request, Context context,
boolean crossContext) {
+ super(request);
+ this.context = context;
+ this.crossContext = crossContext;
+ setRequest(request);
+ }
+
+
// ------------------------------------------------- ServletRequest Methods
@Override
@@ -239,7 +229,6 @@ class ApplicationHttpRequest extends
HttpServletRequestWrapper {
return specialAttributes[pos];
}
}
-
}
@@ -259,11 +248,9 @@ class ApplicationHttpRequest extends
HttpServletRequestWrapper {
*/
@Override
public void removeAttribute(String name) {
-
if (!removeSpecial(name)) {
getRequest().removeAttribute(name);
}
-
}
@@ -287,7 +274,6 @@ class ApplicationHttpRequest extends
HttpServletRequestWrapper {
if (!setSpecial(name, value)) {
getRequest().setAttribute(name, value);
}
-
}
@@ -352,7 +338,6 @@ class ApplicationHttpRequest extends
HttpServletRequestWrapper {
}
return context.getServletContext().getRequestDispatcher(relative);
-
}
@@ -367,7 +352,6 @@ class ApplicationHttpRequest extends
HttpServletRequestWrapper {
// --------------------------------------------- HttpServletRequest Methods
-
/**
* Override the <code>getContextPath()</code> method of the wrapped
request.
*/
@@ -549,7 +533,6 @@ class ApplicationHttpRequest extends
HttpServletRequestWrapper {
} else {
return super.getSession(create);
}
-
}
@@ -630,9 +613,7 @@ class ApplicationHttpRequest extends
HttpServletRequestWrapper {
* @param contextPath The new context path
*/
void setContextPath(String contextPath) {
-
this.contextPath = contextPath;
-
}
@@ -642,9 +623,7 @@ class ApplicationHttpRequest extends
HttpServletRequestWrapper {
* @param pathInfo The new path info
*/
void setPathInfo(String pathInfo) {
-
this.pathInfo = pathInfo;
-
}
@@ -654,9 +633,7 @@ class ApplicationHttpRequest extends
HttpServletRequestWrapper {
* @param queryString The new query string
*/
void setQueryString(String queryString) {
-
this.queryString = queryString;
-
}
@@ -689,9 +666,7 @@ class ApplicationHttpRequest extends
HttpServletRequestWrapper {
* @param requestURI The new request URI
*/
void setRequestURI(String requestURI) {
-
this.requestURI = requestURI;
-
}
@@ -701,9 +676,7 @@ class ApplicationHttpRequest extends
HttpServletRequestWrapper {
* @param servletPath The new servlet path
*/
void setServletPath(String servletPath) {
-
this.servletPath = servletPath;
-
}
@@ -755,7 +728,6 @@ class ApplicationHttpRequest extends
HttpServletRequestWrapper {
}
}
return false;
-
}
@@ -834,7 +806,6 @@ class ApplicationHttpRequest extends
HttpServletRequestWrapper {
// ------------------------------------------------------ Private Methods
-
/**
* Merge the parameters from the saved query parameter string (if any),
and the parameters already present on this
* request (if any), such that the parameter values from the query string
show up first if there are duplicate
@@ -889,7 +860,6 @@ class ApplicationHttpRequest extends
HttpServletRequestWrapper {
// ----------------------------------- AttributeNamesEnumerator Inner Class
-
/**
* Utility class used to expose the special attributes as being available
as request attributes.
*/
@@ -946,8 +916,5 @@ class ApplicationHttpRequest extends
HttpServletRequestWrapper {
}
return result;
}
-
}
-
-
}
diff --git a/java/org/apache/catalina/core/ApplicationRequest.java
b/java/org/apache/catalina/core/ApplicationRequest.java
index 6a5a7bae2f..03cfa72009 100644
--- a/java/org/apache/catalina/core/ApplicationRequest.java
+++ b/java/org/apache/catalina/core/ApplicationRequest.java
@@ -16,7 +16,6 @@
*/
package org.apache.catalina.core;
-
import java.util.Collections;
import java.util.Enumeration;
import java.util.HashMap;
@@ -25,7 +24,6 @@ import javax.servlet.RequestDispatcher;
import javax.servlet.ServletRequest;
import javax.servlet.ServletRequestWrapper;
-
/**
* Wrapper around a <code>javax.servlet.ServletRequest</code> that transforms
an application request object (which might
* be the original one passed to a servlet, or might be based on the 2.3
@@ -41,9 +39,6 @@ import javax.servlet.ServletRequestWrapper;
class ApplicationRequest extends ServletRequestWrapper {
- // ------------------------------------------------------- Static Variables
-
-
/**
* The set of attribute names that are special for request dispatchers.
*/
@@ -55,7 +50,10 @@ class ApplicationRequest extends ServletRequestWrapper {
RequestDispatcher.FORWARD_PATH_INFO,
RequestDispatcher.FORWARD_QUERY_STRING };
- // ----------------------------------------------------------- Constructors
+ /**
+ * The request attributes for this request. This is initialized from the
wrapped request, but updates are allowed.
+ */
+ protected final HashMap<String,Object> attributes = new HashMap<>();
/**
@@ -64,25 +62,13 @@ class ApplicationRequest extends ServletRequestWrapper {
* @param request The servlet request being wrapped
*/
ApplicationRequest(ServletRequest request) {
-
super(request);
setRequest(request);
-
}
- // ----------------------------------------------------- Instance Variables
-
-
- /**
- * The request attributes for this request. This is initialized from the
wrapped request, but updates are allowed.
- */
- protected final HashMap<String,Object> attributes = new HashMap<>();
-
-
// ------------------------------------------------- ServletRequest Methods
-
/**
* Override the <code>getAttribute()</code> method of the wrapped request.
*
@@ -90,11 +76,9 @@ class ApplicationRequest extends ServletRequestWrapper {
*/
@Override
public Object getAttribute(String name) {
-
synchronized (attributes) {
return attributes.get(name);
}
-
}
@@ -103,11 +87,9 @@ class ApplicationRequest extends ServletRequestWrapper {
*/
@Override
public Enumeration<String> getAttributeNames() {
-
synchronized (attributes) {
return Collections.enumeration(attributes.keySet());
}
-
}
@@ -118,14 +100,12 @@ class ApplicationRequest extends ServletRequestWrapper {
*/
@Override
public void removeAttribute(String name) {
-
synchronized (attributes) {
attributes.remove(name);
if (!isSpecial(name)) {
getRequest().removeAttribute(name);
}
}
-
}
@@ -137,20 +117,17 @@ class ApplicationRequest extends ServletRequestWrapper {
*/
@Override
public void setAttribute(String name, Object value) {
-
synchronized (attributes) {
attributes.put(name, value);
if (!isSpecial(name)) {
getRequest().setAttribute(name, value);
}
}
-
}
// ------------------------------------------ ServletRequestWrapper Methods
-
/**
* Set the request that we are wrapping.
*
@@ -158,7 +135,6 @@ class ApplicationRequest extends ServletRequestWrapper {
*/
@Override
public void setRequest(ServletRequest request) {
-
super.setRequest(request);
// Initialize the attributes for this request
@@ -171,28 +147,22 @@ class ApplicationRequest extends ServletRequestWrapper {
attributes.put(name, value);
}
}
-
}
// ------------------------------------------------------ Protected Methods
-
/**
* Is this attribute name one of the special ones that is added only for
included servlets?
*
* @param name Attribute name to be tested
*/
protected boolean isSpecial(String name) {
-
for (String special : specials) {
if (special.equals(name)) {
return true;
}
}
return false;
-
}
-
-
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]