This is an automated email from the ASF dual-hosted git repository.
markt pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/9.0.x by this push:
new be1c0abdfc Clean-up - no functional change
be1c0abdfc is described below
commit be1c0abdfc589e6f471282a4d10c272ffe5feea8
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 cc86ba88db..ae21815fe4 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;
@@ -54,7 +53,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
@@ -86,29 +84,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.
*/
@@ -199,6 +174,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
@@ -242,7 +232,6 @@ class ApplicationHttpRequest extends
HttpServletRequestWrapper {
return specialAttributes[pos];
}
}
-
}
@@ -262,11 +251,9 @@ class ApplicationHttpRequest extends
HttpServletRequestWrapper {
*/
@Override
public void removeAttribute(String name) {
-
if (!removeSpecial(name)) {
getRequest().removeAttribute(name);
}
-
}
@@ -290,7 +277,6 @@ class ApplicationHttpRequest extends
HttpServletRequestWrapper {
if (!setSpecial(name, value)) {
getRequest().setAttribute(name, value);
}
-
}
@@ -355,7 +341,6 @@ class ApplicationHttpRequest extends
HttpServletRequestWrapper {
}
return context.getServletContext().getRequestDispatcher(relative);
-
}
@@ -370,7 +355,6 @@ class ApplicationHttpRequest extends
HttpServletRequestWrapper {
// --------------------------------------------- HttpServletRequest Methods
-
/**
* Override the <code>getContextPath()</code> method of the wrapped
request.
*/
@@ -553,7 +537,6 @@ class ApplicationHttpRequest extends
HttpServletRequestWrapper {
} else {
return super.getSession(create);
}
-
}
@@ -635,9 +618,7 @@ class ApplicationHttpRequest extends
HttpServletRequestWrapper {
* @param contextPath The new context path
*/
void setContextPath(String contextPath) {
-
this.contextPath = contextPath;
-
}
@@ -647,9 +628,7 @@ class ApplicationHttpRequest extends
HttpServletRequestWrapper {
* @param pathInfo The new path info
*/
void setPathInfo(String pathInfo) {
-
this.pathInfo = pathInfo;
-
}
@@ -659,9 +638,7 @@ class ApplicationHttpRequest extends
HttpServletRequestWrapper {
* @param queryString The new query string
*/
void setQueryString(String queryString) {
-
this.queryString = queryString;
-
}
@@ -694,9 +671,7 @@ class ApplicationHttpRequest extends
HttpServletRequestWrapper {
* @param requestURI The new request URI
*/
void setRequestURI(String requestURI) {
-
this.requestURI = requestURI;
-
}
@@ -706,9 +681,7 @@ class ApplicationHttpRequest extends
HttpServletRequestWrapper {
* @param servletPath The new servlet path
*/
void setServletPath(String servletPath) {
-
this.servletPath = servletPath;
-
}
@@ -760,7 +733,6 @@ class ApplicationHttpRequest extends
HttpServletRequestWrapper {
}
}
return false;
-
}
@@ -839,7 +811,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
@@ -895,7 +866,6 @@ class ApplicationHttpRequest extends
HttpServletRequestWrapper {
// ----------------------------------- AttributeNamesEnumerator Inner Class
-
/**
* Utility class used to expose the special attributes as being available
as request attributes.
*/
@@ -952,8 +922,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 c3a5700e14..c3fcacd036 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.
*/
@@ -56,7 +51,10 @@ class ApplicationRequest extends ServletRequestWrapper {
RequestDispatcher.FORWARD_QUERY_STRING,
RequestDispatcher.FORWARD_MAPPING };
- // ----------------------------------------------------------- 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<>();
/**
@@ -65,25 +63,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.
*
@@ -91,11 +77,9 @@ class ApplicationRequest extends ServletRequestWrapper {
*/
@Override
public Object getAttribute(String name) {
-
synchronized (attributes) {
return attributes.get(name);
}
-
}
@@ -104,11 +88,9 @@ class ApplicationRequest extends ServletRequestWrapper {
*/
@Override
public Enumeration<String> getAttributeNames() {
-
synchronized (attributes) {
return Collections.enumeration(attributes.keySet());
}
-
}
@@ -119,14 +101,12 @@ class ApplicationRequest extends ServletRequestWrapper {
*/
@Override
public void removeAttribute(String name) {
-
synchronized (attributes) {
attributes.remove(name);
if (!isSpecial(name)) {
getRequest().removeAttribute(name);
}
}
-
}
@@ -138,20 +118,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.
*
@@ -159,7 +136,6 @@ class ApplicationRequest extends ServletRequestWrapper {
*/
@Override
public void setRequest(ServletRequest request) {
-
super.setRequest(request);
// Initialize the attributes for this request
@@ -172,28 +148,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]