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 2020/04/03 17:40:45 UTC

[tomcat] branch 8.5.x updated (b7a92ad -> 0be3e38)

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

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


    from b7a92ad  Increment version number for next development cycle
     new f57e3f7  Refactoring: Extract inner class
     new aa7271f  Refactor: Replace MappingMatch enum with ApplicationMappingMatch
     new 1a87ea8  Refactor: Remove HttpServletMapping interface
     new 0be3e38  Refactoring: Remove remainder of servlet4preview package

The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 java/javax/el/ImportHandler.java                   |   2 +-
 java/org/apache/catalina/connector/Request.java    |   7 +-
 .../apache/catalina/connector/RequestFacade.java   |  13 +-
 .../apache/catalina/core/ApplicationContext.java   |   3 +-
 .../catalina/core/ApplicationDispatcher.java       |  23 +--
 .../catalina/core/ApplicationHttpRequest.java      |  18 +-
 .../apache/catalina/core/ApplicationMapping.java   |  67 +++----
 .../core/ApplicationMappingImpl.java}              |  44 +++--
 .../ApplicationMappingMatch.java}                  |   6 +-
 .../org/apache/catalina/filters/ExpiresFilter.java |  30 ++--
 java/org/apache/catalina/mapper/Mapper.java        |  12 +-
 java/org/apache/catalina/mapper/MappingData.java   |   4 +-
 .../servlet4preview/http/HttpServletMapping.java   |  53 ------
 .../servlet4preview/http/HttpServletRequest.java   |  25 ---
 .../http/HttpServletRequestWrapper.java            |  53 ------
 ...estApplicationContextGetRequestDispatcherB.java | 198 ++++++++++-----------
 .../catalina/core/TestApplicationMapping.java      |  10 +-
 webapps/docs/changelog.xml                         |  10 ++
 18 files changed, 201 insertions(+), 377 deletions(-)
 copy java/org/apache/{tomcat/util/descriptor/web/InjectionTarget.java => catalina/core/ApplicationMappingImpl.java} (51%)
 rename java/org/apache/catalina/{servlet4preview/http/MappingMatch.java => core/ApplicationMappingMatch.java} (90%)
 delete mode 100644 java/org/apache/catalina/servlet4preview/http/HttpServletMapping.java
 delete mode 100644 java/org/apache/catalina/servlet4preview/http/HttpServletRequest.java
 delete mode 100644 java/org/apache/catalina/servlet4preview/http/HttpServletRequestWrapper.java


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


[tomcat] 02/04: Refactor: Replace MappingMatch enum with ApplicationMappingMatch

Posted by ma...@apache.org.
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

commit aa7271f41b730edbfe4a069f97b29840f31a2029
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Fri Apr 3 16:53:53 2020 +0100

    Refactor: Replace MappingMatch enum with ApplicationMappingMatch
---
 java/javax/el/ImportHandler.java                   |   2 +-
 .../catalina/core/ApplicationMappingImpl.java      |   7 +-
 .../ApplicationMappingMatch.java}                  |   6 +-
 .../org/apache/catalina/filters/ExpiresFilter.java |   4 +-
 java/org/apache/catalina/mapper/Mapper.java        |  12 +-
 java/org/apache/catalina/mapper/MappingData.java   |   4 +-
 .../servlet4preview/http/HttpServletMapping.java   |   4 +-
 ...estApplicationContextGetRequestDispatcherB.java | 189 ++++++++++-----------
 8 files changed, 113 insertions(+), 115 deletions(-)

diff --git a/java/javax/el/ImportHandler.java b/java/javax/el/ImportHandler.java
index b31a75f..151b3ab 100644
--- a/java/javax/el/ImportHandler.java
+++ b/java/javax/el/ImportHandler.java
@@ -114,7 +114,7 @@ public class ImportHandler {
         servletHttpClassNames.add("HttpSessionEvent");
         servletHttpClassNames.add("HttpUtils");
         // Enums
-        servletHttpClassNames.add("MappingMatch");
+        servletHttpClassNames.add("ApplicationMappingMatch");
         standardPackages.put("javax.servlet.http", servletHttpClassNames);
 
         // JSP 2.3
diff --git a/java/org/apache/catalina/core/ApplicationMappingImpl.java b/java/org/apache/catalina/core/ApplicationMappingImpl.java
index e8d21c6..cf64d24 100644
--- a/java/org/apache/catalina/core/ApplicationMappingImpl.java
+++ b/java/org/apache/catalina/core/ApplicationMappingImpl.java
@@ -1,16 +1,15 @@
 package org.apache.catalina.core;
 
 import org.apache.catalina.servlet4preview.http.HttpServletMapping;
-import org.apache.catalina.servlet4preview.http.MappingMatch;
 
 public class ApplicationMappingImpl implements HttpServletMapping {
 
     private final String matchValue;
     private final String pattern;
-    private final MappingMatch mappingType;
+    private final ApplicationMappingMatch mappingType;
     private final String servletName;
 
-    public ApplicationMappingImpl(String matchValue, String pattern, MappingMatch mappingType, String servletName) {
+    public ApplicationMappingImpl(String matchValue, String pattern, ApplicationMappingMatch mappingType, String servletName) {
         this.matchValue = matchValue;
         this.pattern = pattern;
         this.mappingType = mappingType;
@@ -28,7 +27,7 @@ public class ApplicationMappingImpl implements HttpServletMapping {
     }
 
     @Override
-    public MappingMatch getMappingMatch() {
+    public ApplicationMappingMatch getMappingMatch() {
         return mappingType;
     }
 
diff --git a/java/org/apache/catalina/servlet4preview/http/MappingMatch.java b/java/org/apache/catalina/core/ApplicationMappingMatch.java
similarity index 90%
rename from java/org/apache/catalina/servlet4preview/http/MappingMatch.java
rename to java/org/apache/catalina/core/ApplicationMappingMatch.java
index 3dd54b0..cb1a9d8 100644
--- a/java/org/apache/catalina/servlet4preview/http/MappingMatch.java
+++ b/java/org/apache/catalina/core/ApplicationMappingMatch.java
@@ -14,14 +14,12 @@
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
-package org.apache.catalina.servlet4preview.http;
+package org.apache.catalina.core;
 
 /**
  * Represents the ways that a request can be mapped to a servlet
- *
- * @since 4.0
  */
-public enum MappingMatch {
+public enum ApplicationMappingMatch {
 
     CONTEXT_ROOT,
     DEFAULT,
diff --git a/java/org/apache/catalina/filters/ExpiresFilter.java b/java/org/apache/catalina/filters/ExpiresFilter.java
index 8f1dab4..6c7ff78 100644
--- a/java/org/apache/catalina/filters/ExpiresFilter.java
+++ b/java/org/apache/catalina/filters/ExpiresFilter.java
@@ -42,7 +42,7 @@ import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import javax.servlet.http.HttpServletResponseWrapper;
 
-import org.apache.catalina.servlet4preview.http.MappingMatch;
+import org.apache.catalina.core.ApplicationMappingMatch;
 import org.apache.juli.logging.Log;
 import org.apache.juli.logging.LogFactory;
 
@@ -1296,7 +1296,7 @@ public class ExpiresFilter extends FilterBase {
                 org.apache.catalina.servlet4preview.http.HttpServletRequest servlet4Request =
                         (org.apache.catalina.servlet4preview.http.HttpServletRequest) innerRequest;
 
-                if (servlet4Request.getHttpServletMapping().getMappingMatch() == MappingMatch.DEFAULT &&
+                if (servlet4Request.getHttpServletMapping().getMappingMatch() == ApplicationMappingMatch.DEFAULT &&
                         response.getStatus() == HttpServletResponse.SC_NOT_MODIFIED) {
                     // Default servlet normally sets the content type but does not for
                     // 304 responses. Look it up.
diff --git a/java/org/apache/catalina/mapper/Mapper.java b/java/org/apache/catalina/mapper/Mapper.java
index f8b6606..02dd2d1 100644
--- a/java/org/apache/catalina/mapper/Mapper.java
+++ b/java/org/apache/catalina/mapper/Mapper.java
@@ -30,7 +30,7 @@ import org.apache.catalina.Host;
 import org.apache.catalina.WebResource;
 import org.apache.catalina.WebResourceRoot;
 import org.apache.catalina.Wrapper;
-import org.apache.catalina.servlet4preview.http.MappingMatch;
+import org.apache.catalina.core.ApplicationMappingMatch;
 import org.apache.juli.logging.Log;
 import org.apache.juli.logging.LogFactory;
 import org.apache.tomcat.util.buf.Ascii;
@@ -1019,7 +1019,7 @@ public final class Mapper {
                     (path.getBuffer(), path.getStart(), path.getLength());
                 mappingData.wrapperPath.setChars
                     (path.getBuffer(), path.getStart(), path.getLength());
-                mappingData.matchType = MappingMatch.DEFAULT;
+                mappingData.matchType = ApplicationMappingMatch.DEFAULT;
             }
             // Redirection to a folder
             char[] buf = path.getBuffer();
@@ -1075,10 +1075,10 @@ public final class Mapper {
                 mappingData.wrapperPath.setString("");
                 // This seems wrong but it is what the spec says...
                 mappingData.contextPath.setString("");
-                mappingData.matchType = MappingMatch.CONTEXT_ROOT;
+                mappingData.matchType = ApplicationMappingMatch.CONTEXT_ROOT;
             } else {
                 mappingData.wrapperPath.setString(wrapper.name);
-                mappingData.matchType = MappingMatch.EXACT;
+                mappingData.matchType = ApplicationMappingMatch.EXACT;
             }
         }
     }
@@ -1130,7 +1130,7 @@ public final class Mapper {
                     (path.getBuffer(), path.getOffset(), path.getLength());
                 mappingData.wrapper = wrappers[pos].object;
                 mappingData.jspWildCard = wrappers[pos].jspWildCard;
-                mappingData.matchType = MappingMatch.PATH;
+                mappingData.matchType = ApplicationMappingMatch.PATH;
             }
         }
     }
@@ -1175,7 +1175,7 @@ public final class Mapper {
                     mappingData.requestPath.setChars(buf, servletPath, pathEnd
                             - servletPath);
                     mappingData.wrapper = wrapper.object;
-                    mappingData.matchType = MappingMatch.EXTENSION;
+                    mappingData.matchType = ApplicationMappingMatch.EXTENSION;
                 }
                 path.setOffset(servletPath);
                 path.setEnd(pathEnd);
diff --git a/java/org/apache/catalina/mapper/MappingData.java b/java/org/apache/catalina/mapper/MappingData.java
index 7578f49..9ad15be 100644
--- a/java/org/apache/catalina/mapper/MappingData.java
+++ b/java/org/apache/catalina/mapper/MappingData.java
@@ -20,7 +20,7 @@ package org.apache.catalina.mapper;
 import org.apache.catalina.Context;
 import org.apache.catalina.Host;
 import org.apache.catalina.Wrapper;
-import org.apache.catalina.servlet4preview.http.MappingMatch;
+import org.apache.catalina.core.ApplicationMappingMatch;
 import org.apache.tomcat.util.buf.MessageBytes;
 
 /**
@@ -49,7 +49,7 @@ public class MappingData {
     public final MessageBytes redirectPath = MessageBytes.newInstance();
 
     // Fields used by ApplicationMapping to implement javax.servlet.http.HttpServletMapping
-    public MappingMatch matchType = null;
+    public ApplicationMappingMatch matchType = null;
 
     public void recycle() {
         host = null;
diff --git a/java/org/apache/catalina/servlet4preview/http/HttpServletMapping.java b/java/org/apache/catalina/servlet4preview/http/HttpServletMapping.java
index 3a14feb..cad96e1 100644
--- a/java/org/apache/catalina/servlet4preview/http/HttpServletMapping.java
+++ b/java/org/apache/catalina/servlet4preview/http/HttpServletMapping.java
@@ -18,6 +18,8 @@ package org.apache.catalina.servlet4preview.http;
 
 import javax.servlet.annotation.WebServlet;
 
+import org.apache.catalina.core.ApplicationMappingMatch;
+
 /**
  * Represents how the request from which this object was obtained was mapped to
  * the associated servlet.
@@ -49,5 +51,5 @@ public interface HttpServletMapping {
     /**
      * @return The type of match ({@code null} if not known)
      */
-    MappingMatch getMappingMatch();
+    ApplicationMappingMatch getMappingMatch();
 }
diff --git a/test/org/apache/catalina/core/TestApplicationContextGetRequestDispatcherB.java b/test/org/apache/catalina/core/TestApplicationContextGetRequestDispatcherB.java
index ca74a95..be1b8a4 100755
--- a/test/org/apache/catalina/core/TestApplicationContextGetRequestDispatcherB.java
+++ b/test/org/apache/catalina/core/TestApplicationContextGetRequestDispatcherB.java
@@ -39,7 +39,6 @@ import org.junit.runners.Parameterized.Parameters;
 import org.apache.catalina.Context;
 import org.apache.catalina.Wrapper;
 import org.apache.catalina.servlet4preview.http.HttpServletMapping;
-import org.apache.catalina.servlet4preview.http.MappingMatch;
 import org.apache.catalina.startup.Tomcat;
 import org.apache.catalina.startup.TomcatBaseTest;
 import org.apache.tomcat.util.buf.ByteChunk;
@@ -64,135 +63,135 @@ public class TestApplicationContextGetRequestDispatcherB extends TomcatBaseTest
             // Simple dispatch for each type
             { "/start", "/start", DispatcherType.INCLUDE, "/target", "/target", Boolean.TRUE,
                     "/test/start", "/test", "/start", null, null,
-                    MappingMatch.EXACT, "/start", "start", "rd",
+                    ApplicationMappingMatch.EXACT, "/start", "start", "rd",
                     "/test/target", "/test", "/target", null, null,
-                    MappingMatch.EXACT, "/target", "target", "target",
+                    ApplicationMappingMatch.EXACT, "/target", "target", "target",
                     "OK"},
             { "/start", "/start", DispatcherType.FORWARD, "/target", "/target", Boolean.TRUE,
                     "/test/target", "/test", "/target", null, null,
-                    MappingMatch.EXACT, "/target", "target", "target",
+                    ApplicationMappingMatch.EXACT, "/target", "target", "target",
                     "/test/start", "/test", "/start", null, null,
-                    MappingMatch.EXACT, "/start", "start", "rd",
+                    ApplicationMappingMatch.EXACT, "/start", "start", "rd",
                     "OK"},
             { "/start", "/start", DispatcherType.ASYNC, "/target", "/target", Boolean.TRUE,
                     "/test/target", "/test", "/target", null, null,
-                    MappingMatch.EXACT, "/target", "target", "target",
+                    ApplicationMappingMatch.EXACT, "/target", "target", "target",
                     "/test/start", "/test", "/start", null, null,
-                    MappingMatch.EXACT, "/start", "start", "rd",
+                    ApplicationMappingMatch.EXACT, "/start", "start", "rd",
                     "OK"},
             // Simple dispatch with query strings
             { "/start", "/start?abcde=fghij", DispatcherType.INCLUDE, "/target", "/target?zyxwv=utsrq", Boolean.TRUE,
                     "/test/start", "/test", "/start", null, "abcde=fghij",
-                    MappingMatch.EXACT, "/start", "start", "rd",
+                    ApplicationMappingMatch.EXACT, "/start", "start", "rd",
                     "/test/target", "/test", "/target", null, "zyxwv=utsrq",
-                    MappingMatch.EXACT, "/target", "target", "target",
+                    ApplicationMappingMatch.EXACT, "/target", "target", "target",
                     "OK"},
             { "/start", "/start?abcde=fghij", DispatcherType.FORWARD, "/target", "/target?zyxwv=utsrq", Boolean.TRUE,
                     "/test/target", "/test", "/target", null, "zyxwv=utsrq",
-                    MappingMatch.EXACT, "/target", "target", "target",
+                    ApplicationMappingMatch.EXACT, "/target", "target", "target",
                     "/test/start", "/test", "/start", null, "abcde=fghij",
-                    MappingMatch.EXACT, "/start", "start", "rd",
+                    ApplicationMappingMatch.EXACT, "/start", "start", "rd",
                     "OK"},
             { "/start", "/start?abcde=fghij", DispatcherType.ASYNC, "/target", "/target?zyxwv=utsrq", Boolean.TRUE,
                     "/test/target", "/test", "/target", null, "zyxwv=utsrq",
-                    MappingMatch.EXACT, "/target", "target", "target",
+                    ApplicationMappingMatch.EXACT, "/target", "target", "target",
                     "/test/start", "/test", "/start", null, "abcde=fghij",
-                    MappingMatch.EXACT, "/start", "start", "rd",
+                    ApplicationMappingMatch.EXACT, "/start", "start", "rd",
                     "OK"},
             // Simple dispatch with trailing path parameters at start
             { "/start", "/start;abcde=fghij", DispatcherType.INCLUDE, "/target", "/target", Boolean.TRUE,
                     "/test/start;abcde=fghij", "/test", "/start", null, null,
-                    MappingMatch.EXACT, "/start", "start", "rd",
+                    ApplicationMappingMatch.EXACT, "/start", "start", "rd",
                     "/test/target", "/test", "/target", null, null,
-                    MappingMatch.EXACT, "/target", "target", "target",
+                    ApplicationMappingMatch.EXACT, "/target", "target", "target",
                     "OK"},
             { "/start", "/start;abcde=fghij", DispatcherType.FORWARD, "/target", "/target", Boolean.TRUE,
                     "/test/target", "/test", "/target", null, null,
-                    MappingMatch.EXACT, "/target", "target", "target",
+                    ApplicationMappingMatch.EXACT, "/target", "target", "target",
                     "/test/start;abcde=fghij", "/test", "/start", null, null,
-                    MappingMatch.EXACT, "/start", "start", "rd",
+                    ApplicationMappingMatch.EXACT, "/start", "start", "rd",
                     "OK"},
             { "/start", "/start;abcde=fghij", DispatcherType.ASYNC, "/target", "/target", Boolean.TRUE,
                     "/test/target", "/test", "/target", null, null,
-                    MappingMatch.EXACT, "/target", "target", "target",
+                    ApplicationMappingMatch.EXACT, "/target", "target", "target",
                     "/test/start;abcde=fghij", "/test", "/start", null, null,
-                    MappingMatch.EXACT, "/start", "start", "rd",
+                    ApplicationMappingMatch.EXACT, "/start", "start", "rd",
                     "OK"},
             // Simple dispatch with path parameters at start
             { "/start", ";abcde=fghij/start", DispatcherType.INCLUDE, "/target", "/target", Boolean.TRUE,
                     "/test;abcde=fghij/start", "/test;abcde=fghij", "/start", null, null,
-                    MappingMatch.EXACT, "/start", "start", "rd",
+                    ApplicationMappingMatch.EXACT, "/start", "start", "rd",
                     "/test/target", "/test", "/target", null, null,
-                    MappingMatch.EXACT, "/target", "target", "target",
+                    ApplicationMappingMatch.EXACT, "/target", "target", "target",
                     "OK"},
             { "/start", ";abcde=fghij/start", DispatcherType.FORWARD, "/target", "/target", Boolean.TRUE,
                     "/test/target", "/test", "/target", null, null,
-                    MappingMatch.EXACT, "/target", "target", "target",
+                    ApplicationMappingMatch.EXACT, "/target", "target", "target",
                     "/test;abcde=fghij/start", "/test;abcde=fghij", "/start", null, null,
-                    MappingMatch.EXACT, "/start", "start", "rd",
+                    ApplicationMappingMatch.EXACT, "/start", "start", "rd",
                     "OK"},
             { "/start", ";abcde=fghij/start", DispatcherType.ASYNC, "/target", "/target", Boolean.TRUE,
                     "/test/target", "/test", "/target", null, null,
-                    MappingMatch.EXACT, "/target", "target", "target",
+                    ApplicationMappingMatch.EXACT, "/target", "target", "target",
                     "/test;abcde=fghij/start", "/test;abcde=fghij", "/start", null, null,
-                    MappingMatch.EXACT, "/start", "start", "rd",
+                    ApplicationMappingMatch.EXACT, "/start", "start", "rd",
                     "OK"},
             // Simple dispatch with path parameters on dispatch
             { "/start", "/start", DispatcherType.INCLUDE, "/target", "/target;abcde=fghij", Boolean.TRUE,
                     "/test/start", "/test", "/start", null, null,
-                    MappingMatch.EXACT, "/start", "start", "rd",
+                    ApplicationMappingMatch.EXACT, "/start", "start", "rd",
                     "/test/target;abcde=fghij", "/test", "/target", null, null,
-                    MappingMatch.EXACT, "/target", "target", "target",
+                    ApplicationMappingMatch.EXACT, "/target", "target", "target",
                     "OK"},
             { "/start", "/start", DispatcherType.FORWARD, "/target", "/target;abcde=fghij", Boolean.TRUE,
                     "/test/target;abcde=fghij", "/test", "/target", null, null,
-                    MappingMatch.EXACT, "/target", "target", "target",
+                    ApplicationMappingMatch.EXACT, "/target", "target", "target",
                     "/test/start", "/test", "/start", null, null,
-                    MappingMatch.EXACT, "/start", "start", "rd",
+                    ApplicationMappingMatch.EXACT, "/start", "start", "rd",
                     "OK"},
             { "/start", "/start", DispatcherType.ASYNC, "/target", "/target;abcde=fghij", Boolean.TRUE,
                     "/test/target;abcde=fghij", "/test", "/target", null, null,
-                    MappingMatch.EXACT, "/target", "target", "target",
+                    ApplicationMappingMatch.EXACT, "/target", "target", "target",
                     "/test/start", "/test", "/start", null, null,
-                    MappingMatch.EXACT, "/start", "start", "rd",
+                    ApplicationMappingMatch.EXACT, "/start", "start", "rd",
                     "OK"},
             // Simple dispatch with multiple path parameters on start and dispatch
             { "/start", "/start;abcde=fghij", DispatcherType.INCLUDE, "/target", ";klmno=pqrst/target;uvwxy=z0123", Boolean.TRUE,
                     "/test/start;abcde=fghij", "/test", "/start", null, null,
-                    MappingMatch.EXACT, "/start", "start", "rd",
+                    ApplicationMappingMatch.EXACT, "/start", "start", "rd",
                     "/test/;klmno=pqrst/target;uvwxy=z0123", "/test", "/target", null, null,
-                    MappingMatch.EXACT, "/target", "target", "target",
+                    ApplicationMappingMatch.EXACT, "/target", "target", "target",
                     "OK"},
             { "/start", "/start;abcde=fghij", DispatcherType.FORWARD, "/target", ";klmno=pqrst/target;uvwxy=z0123", Boolean.TRUE,
                     "/test/;klmno=pqrst/target;uvwxy=z0123", "/test", "/target", null, null,
-                    MappingMatch.EXACT, "/target", "target", "target",
+                    ApplicationMappingMatch.EXACT, "/target", "target", "target",
                     "/test/start;abcde=fghij", "/test", "/start", null, null,
-                    MappingMatch.EXACT, "/start", "start", "rd",
+                    ApplicationMappingMatch.EXACT, "/start", "start", "rd",
                     "OK"},
             { "/start", "/start;abcde=fghij", DispatcherType.ASYNC, "/target", ";klmno=pqrst/target;uvwxy=z0123", Boolean.TRUE,
                     "/test/;klmno=pqrst/target;uvwxy=z0123", "/test", "/target", null, null,
-                    MappingMatch.EXACT, "/target", "target", "target",
+                    ApplicationMappingMatch.EXACT, "/target", "target", "target",
                     "/test/start;abcde=fghij", "/test", "/start", null, null,
-                    MappingMatch.EXACT, "/start", "start", "rd",
+                    ApplicationMappingMatch.EXACT, "/start", "start", "rd",
                     "ASYNC-IAE"},
             // Simple dispatch with directory traversal
             { "/start/*", "/start/foo", DispatcherType.INCLUDE, "/target", "../target", Boolean.TRUE,
                     "/test/start/foo", "/test", "/start", "/foo", null,
-                    MappingMatch.PATH, "/start/*", "foo", "rd",
+                    ApplicationMappingMatch.PATH, "/start/*", "foo", "rd",
                     "/test/start/../target", "/test", "/target", null, null,
-                    MappingMatch.EXACT, "/target", "target", "target",
+                    ApplicationMappingMatch.EXACT, "/target", "target", "target",
                     "OK"},
             { "/start/*", "/start/foo", DispatcherType.FORWARD, "/target", "../target", Boolean.TRUE,
                     "/test/start/../target", "/test", "/target", null, null,
-                    MappingMatch.EXACT, "/target", "target", "target",
+                    ApplicationMappingMatch.EXACT, "/target", "target", "target",
                     "/test/start/foo", "/test", "/start", "/foo", null,
-                    MappingMatch.PATH, "/start/*", "foo", "rd",
+                    ApplicationMappingMatch.PATH, "/start/*", "foo", "rd",
                     "OK"},
             { "/start/*", "/start/foo", DispatcherType.ASYNC, "/target", "../target", Boolean.TRUE,
                     "/test/start/../target", "/test", "/target", null, null,
-                    MappingMatch.EXACT, "/target", "target", "target",
+                    ApplicationMappingMatch.EXACT, "/target", "target", "target",
                     "/test/start/foo", "/test", "/start", "/foo", null,
-                    MappingMatch.PATH, "/start/*", "foo", "rd",
+                    ApplicationMappingMatch.PATH, "/start/*", "foo", "rd",
                     "ASYNC-IAE"},
             // Simple dispatch with directory traversal and path parameters
             // Note comments in Request.getRequestDispatcher(String) that
@@ -200,154 +199,154 @@ public class TestApplicationContextGetRequestDispatcherB extends TomcatBaseTest
             // dispatched requestURI
             { "/start/*", "/start;abcde=fghij/foo", DispatcherType.INCLUDE, "/target", "../target;klmno=pqrst", Boolean.TRUE,
                     "/test/start;abcde=fghij/foo", "/test", "/start", "/foo", null,
-                    MappingMatch.PATH, "/start/*", "foo", "rd",
+                    ApplicationMappingMatch.PATH, "/start/*", "foo", "rd",
                     "/test/start/../target;klmno=pqrst", "/test", "/target", null, null,
-                    MappingMatch.EXACT, "/target", "target", "target",
+                    ApplicationMappingMatch.EXACT, "/target", "target", "target",
                     "OK"},
             { "/start/*", "/start;abcde=fghij/foo", DispatcherType.FORWARD, "/target", "../target;klmno=pqrst", Boolean.TRUE,
                     "/test/start/../target;klmno=pqrst", "/test", "/target", null, null,
-                    MappingMatch.EXACT, "/target", "target", "target",
+                    ApplicationMappingMatch.EXACT, "/target", "target", "target",
                     "/test/start;abcde=fghij/foo", "/test", "/start", "/foo", null,
-                    MappingMatch.PATH, "/start/*", "foo", "rd",
+                    ApplicationMappingMatch.PATH, "/start/*", "foo", "rd",
                     "OK"},
             { "/start/*", "/start;abcde=fghij/foo", DispatcherType.ASYNC, "/target", "../target;klmno=pqrst", Boolean.TRUE,
                     "/test/start;abcde=fghij/../target;klmno=pqrst", "/test", "/target", null, null,
-                    MappingMatch.EXACT, "/target", "target", "target",
+                    ApplicationMappingMatch.EXACT, "/target", "target", "target",
                     "/test/start;abcde=fghij/foo", "/test", "/start", "/foo", null,
-                    MappingMatch.PATH, "/start/*", "foo", "rd",
+                    ApplicationMappingMatch.PATH, "/start/*", "foo", "rd",
                     "ASYNC-IAE"},
             // Simple dispatch with invalid directory traversal
             { "/start/*", "/start/foo", DispatcherType.INCLUDE, "/target", "../../target", Boolean.TRUE,
                     "/test/start/foo", "/test", "/start", "/foo", null,
-                    MappingMatch.PATH, "/start/*", "foo", "rd",
+                    ApplicationMappingMatch.PATH, "/start/*", "foo", "rd",
                     "/test/start/../target", "/test", "/target", null, null,
-                    MappingMatch.EXACT, "/target", "target", "target",
+                    ApplicationMappingMatch.EXACT, "/target", "target", "target",
                     "RD-NULL"},
             { "/start/*", "/start/foo", DispatcherType.FORWARD, "/target", "../../target", Boolean.TRUE,
                     "/test/start/../target", "/test", "/target", null, null,
-                    MappingMatch.EXACT, "/target", "target", "target",
+                    ApplicationMappingMatch.EXACT, "/target", "target", "target",
                     "/test/start/foo", "/test", "/start", "/foo", null,
-                    MappingMatch.PATH, "/start/*", "foo", "rd",
+                    ApplicationMappingMatch.PATH, "/start/*", "foo", "rd",
                     "RD-NULL"},
             { "/start/*", "/start/foo", DispatcherType.ASYNC, "/target", "../../target", Boolean.TRUE,
                     "/test/start/../target", "/test", "/target", null, null,
-                    MappingMatch.EXACT, "/target", "target", "target",
+                    ApplicationMappingMatch.EXACT, "/target", "target", "target",
                     "/test/start/foo", "/test", "/start", "/foo", null,
-                    MappingMatch.PATH, "/start/*", "foo", "rd",
+                    ApplicationMappingMatch.PATH, "/start/*", "foo", "rd",
                     "ASYNC-IAE"},
             // Simple dispatch with invalid target
             { "/start", "/start", DispatcherType.INCLUDE, "/target", "/does-not-exist", Boolean.TRUE,
                     "/test/start", "/test", "/start", null, null,
-                    MappingMatch.EXACT, "/start", "start", "rd",
+                    ApplicationMappingMatch.EXACT, "/start", "start", "rd",
                     "/test/target", "/test", "/target", null, null,
-                    MappingMatch.EXACT, "/target", "target", "target",
+                    ApplicationMappingMatch.EXACT, "/target", "target", "target",
                     "RD-NULL"},
             { "/start", "/start", DispatcherType.FORWARD, "/target", "/does-not-exist", Boolean.TRUE,
                     "/test/target", "/test", "/target", null, null,
-                    MappingMatch.EXACT, "/target", "target", "target",
+                    ApplicationMappingMatch.EXACT, "/target", "target", "target",
                     "/test/start", "/test", "/start", null, null,
-                    MappingMatch.EXACT, "/start", "start", "rd",
+                    ApplicationMappingMatch.EXACT, "/start", "start", "rd",
                     "RD-NULL"},
             { "/start", "/start", DispatcherType.ASYNC, "/target", "/does-not-exist", Boolean.TRUE,
                     "/test/target", "/test", "/target", null, null,
-                    MappingMatch.EXACT, "/target", "target", "target",
+                    ApplicationMappingMatch.EXACT, "/target", "target", "target",
                     "/test/start", "/test", "/start", null, null,
-                    MappingMatch.EXACT, "/start", "start", "rd",
+                    ApplicationMappingMatch.EXACT, "/start", "start", "rd",
                     "ASYNC-RD-NULL"},
             // Welcome files
             { "/start", "/start", DispatcherType.INCLUDE, "*.html", "/", Boolean.TRUE,
                     "/test/start", "/test", "/start", null, null,
-                    MappingMatch.EXACT, "/start", "start", "rd",
+                    ApplicationMappingMatch.EXACT, "/start", "start", "rd",
                     "/test/", "/test", "/index.html", null, null,
-                    MappingMatch.EXTENSION, "*.html", "index", "target",
+                    ApplicationMappingMatch.EXTENSION, "*.html", "index", "target",
                     "OK"},
             { "/start", "/start", DispatcherType.FORWARD, "*.html", "/", Boolean.TRUE,
                     "/test/", "/test", "/index.html", null, null,
-                    MappingMatch.EXTENSION, "*.html", "index", "target",
+                    ApplicationMappingMatch.EXTENSION, "*.html", "index", "target",
                     "/test/start", "/test", "/start", null, null,
-                    MappingMatch.EXACT, "/start", "start", "rd",
+                    ApplicationMappingMatch.EXACT, "/start", "start", "rd",
                     "OK"},
             { "/start", "/start", DispatcherType.ASYNC, "*.html", "/", Boolean.TRUE,
                     "/test/", "/test", "/index.html", null, null,
-                    MappingMatch.EXTENSION, "*.html", "index", "target",
+                    ApplicationMappingMatch.EXTENSION, "*.html", "index", "target",
                     "/test/start", "/test", "/start", null, null,
-                    MappingMatch.EXACT, "/start", "start", "rd",
+                    ApplicationMappingMatch.EXACT, "/start", "start", "rd",
                     "OK"},
             // Welcome files with query strings
             { "/start", "/start?abcde=fghij", DispatcherType.INCLUDE, "*.html", "/?zyxwv=utsrq", Boolean.TRUE,
                     "/test/start", "/test", "/start", null, "abcde=fghij",
-                    MappingMatch.EXACT, "/start", "start", "rd",
+                    ApplicationMappingMatch.EXACT, "/start", "start", "rd",
                     "/test/", "/test", "/index.html", null, "zyxwv=utsrq",
-                    MappingMatch.EXTENSION, "*.html", "index", "target",
+                    ApplicationMappingMatch.EXTENSION, "*.html", "index", "target",
                     "OK"},
             { "/start", "/start?abcde=fghij", DispatcherType.FORWARD, "*.html", "/?zyxwv=utsrq", Boolean.TRUE,
                     "/test/", "/test", "/index.html", null, "zyxwv=utsrq",
-                    MappingMatch.EXTENSION, "*.html", "index", "target",
+                    ApplicationMappingMatch.EXTENSION, "*.html", "index", "target",
                     "/test/start", "/test", "/start", null, "abcde=fghij",
-                    MappingMatch.EXACT, "/start", "start", "rd",
+                    ApplicationMappingMatch.EXACT, "/start", "start", "rd",
                     "OK"},
             { "/start", "/start?abcde=fghij", DispatcherType.ASYNC, "*.html", "/?zyxwv=utsrq", Boolean.TRUE,
                     "/test/", "/test", "/index.html", null, "zyxwv=utsrq",
-                    MappingMatch.EXTENSION, "*.html", "index", "target",
+                    ApplicationMappingMatch.EXTENSION, "*.html", "index", "target",
                     "/test/start", "/test", "/start", null, "abcde=fghij",
-                    MappingMatch.EXACT, "/start", "start", "rd",
+                    ApplicationMappingMatch.EXACT, "/start", "start", "rd",
                     "OK"},
             // Welcome files with trailing path parameters at start
             { "/start", "/start;abcde=fghij", DispatcherType.INCLUDE, "*.html", "/", Boolean.TRUE,
                     "/test/start;abcde=fghij", "/test", "/start", null, null,
-                    MappingMatch.EXACT, "/start", "start", "rd",
+                    ApplicationMappingMatch.EXACT, "/start", "start", "rd",
                     "/test/", "/test", "/index.html", null, null,
-                    MappingMatch.EXTENSION, "*.html", "index", "target",
+                    ApplicationMappingMatch.EXTENSION, "*.html", "index", "target",
                     "OK"},
             { "/start", "/start;abcde=fghij", DispatcherType.FORWARD, "*.html", "/", Boolean.TRUE,
                     "/test/", "/test", "/index.html", null, null,
-                    MappingMatch.EXTENSION, "*.html", "index", "target",
+                    ApplicationMappingMatch.EXTENSION, "*.html", "index", "target",
                     "/test/start;abcde=fghij", "/test", "/start", null, null,
-                    MappingMatch.EXACT, "/start", "start", "rd",
+                    ApplicationMappingMatch.EXACT, "/start", "start", "rd",
                     "OK"},
             { "/start", "/start;abcde=fghij", DispatcherType.ASYNC, "*.html", "/", Boolean.TRUE,
                     "/test/", "/test", "/index.html", null, null,
-                    MappingMatch.EXTENSION, "*.html", "index", "target",
+                    ApplicationMappingMatch.EXTENSION, "*.html", "index", "target",
                     "/test/start;abcde=fghij", "/test", "/start", null, null,
-                    MappingMatch.EXACT, "/start", "start", "rd",
+                    ApplicationMappingMatch.EXACT, "/start", "start", "rd",
                     "OK"},
             // Welcome files with path parameters at start
             { "/start", ";abcde=fghij/start", DispatcherType.INCLUDE, "*.html", "/", Boolean.TRUE,
                     "/test;abcde=fghij/start", "/test;abcde=fghij", "/start", null, null,
-                    MappingMatch.EXACT, "/start", "start", "rd",
+                    ApplicationMappingMatch.EXACT, "/start", "start", "rd",
                     "/test/", "/test", "/index.html", null, null,
-                    MappingMatch.EXTENSION, "*.html", "index", "target",
+                    ApplicationMappingMatch.EXTENSION, "*.html", "index", "target",
                     "OK"},
             { "/start", ";abcde=fghij/start", DispatcherType.FORWARD, "*.html", "/", Boolean.TRUE,
                     "/test/", "/test", "/index.html", null, null,
-                    MappingMatch.EXTENSION, "*.html", "index", "target",
+                    ApplicationMappingMatch.EXTENSION, "*.html", "index", "target",
                     "/test;abcde=fghij/start", "/test;abcde=fghij", "/start", null, null,
-                    MappingMatch.EXACT, "/start", "start", "rd",
+                    ApplicationMappingMatch.EXACT, "/start", "start", "rd",
                     "OK"},
             { "/start", ";abcde=fghij/start", DispatcherType.ASYNC, "*.html", "/", Boolean.TRUE,
                     "/test/", "/test", "/index.html", null, null,
-                    MappingMatch.EXTENSION, "*.html", "index", "target",
+                    ApplicationMappingMatch.EXTENSION, "*.html", "index", "target",
                     "/test;abcde=fghij/start", "/test;abcde=fghij", "/start", null, null,
-                    MappingMatch.EXACT, "/start", "start", "rd",
+                    ApplicationMappingMatch.EXACT, "/start", "start", "rd",
                     "OK"},
             // Welcome files with trailing path parameters on dispatch
             { "/start", "/start", DispatcherType.INCLUDE, "*.html", "/;abcde=fghij", Boolean.TRUE,
                     "/test/start", "/test", "/start", null, null,
-                    MappingMatch.EXACT, "/start", "start", "rd",
+                    ApplicationMappingMatch.EXACT, "/start", "start", "rd",
                     "/test/;abcde=fghij", "/test", "/index.html", null, null,
-                    MappingMatch.EXTENSION, "*.html", "index", "target",
+                    ApplicationMappingMatch.EXTENSION, "*.html", "index", "target",
                     "OK"},
             { "/start", "/start", DispatcherType.FORWARD, "*.html", "/;abcde=fghij", Boolean.TRUE,
                     "/test/;abcde=fghij", "/test", "/index.html", null, null,
-                    MappingMatch.EXTENSION, "*.html", "index", "target",
+                    ApplicationMappingMatch.EXTENSION, "*.html", "index", "target",
                     "/test/start", "/test", "/start", null, null,
-                    MappingMatch.EXACT, "/start", "start", "rd",
+                    ApplicationMappingMatch.EXACT, "/start", "start", "rd",
                     "OK"},
             { "/start", "/start", DispatcherType.ASYNC, "*.html", "/;abcde=fghij", Boolean.TRUE,
                     "/test/;abcde=fghij", "/test", "/index.html", null, null,
-                    MappingMatch.EXTENSION, "*.html", "index", "target",
+                    ApplicationMappingMatch.EXTENSION, "*.html", "index", "target",
                     "/test/start", "/test", "/start", null, null,
-                    MappingMatch.EXACT, "/start", "start", "rd",
+                    ApplicationMappingMatch.EXACT, "/start", "start", "rd",
                     "OK"},
         });
     }
@@ -365,7 +364,7 @@ public class TestApplicationContextGetRequestDispatcherB extends TomcatBaseTest
     private final String expectedServletPath;
     private final String expectedPathInfo;
     private final String expectedQueryString;
-    private final MappingMatch expectedMappingMatch;
+    private final ApplicationMappingMatch expectedMappingMatch;
     private final String expectedMappingPattern;
     private final String expectedMappingMatchValue;
     private final String expectedMappingServletName;
@@ -374,7 +373,7 @@ public class TestApplicationContextGetRequestDispatcherB extends TomcatBaseTest
     private final String expectedDispatcherServletPath;
     private final String expectedDispatcherPathInfo;
     private final String expectedDispatcherQueryString;
-    private final MappingMatch expectedDispatcherMappingMatch;
+    private final ApplicationMappingMatch expectedDispatcherMappingMatch;
     private final String expectedDispatcherMappingPattern;
     private final String expectedDispatcherMappingMatchValue;
     private final String expectedDispatcherMappingServletName;
@@ -385,12 +384,12 @@ public class TestApplicationContextGetRequestDispatcherB extends TomcatBaseTest
             DispatcherType dispatcherType, String targetMapping, String targetUri,
             boolean useEncodedDispatchPaths,
             String expectedRequestURI, String expectedContextPath, String expectedServletPath,
-            String expectedPathInfo, String expectedQueryString, MappingMatch expectedMappingMatch,
+            String expectedPathInfo, String expectedQueryString, ApplicationMappingMatch expectedMappingMatch,
             String expectedMappingPattern, String expectedMappingMatchValue,
             String expectedMappingServletName,
             String expectedDispatcherRequestURI, String expectedDispatcherContextPath,
             String expectedDispatcherServletPath, String expectedDispatcherPathInfo,
-            String expectedDispatcherQueryString, MappingMatch expectedDispatcherMappingMatch,
+            String expectedDispatcherQueryString, ApplicationMappingMatch expectedDispatcherMappingMatch,
             String expectedDispatcherMappingPattern, String expectedDispatcherMappingMatchValue,
             String expectedDispatcherMappingServletName,
             String expectedBody) {


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


[tomcat] 01/04: Refactoring: Extract inner class

Posted by ma...@apache.org.
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

commit f57e3f7615dc5b3dafd3cddc70b373b321c86368
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Fri Apr 3 16:50:58 2020 +0100

    Refactoring: Extract inner class
---
 .../apache/catalina/core/ApplicationMapping.java   | 51 +++-------------------
 .../catalina/core/ApplicationMappingImpl.java      | 39 +++++++++++++++++
 2 files changed, 46 insertions(+), 44 deletions(-)

diff --git a/java/org/apache/catalina/core/ApplicationMapping.java b/java/org/apache/catalina/core/ApplicationMapping.java
index 4d28f7a..9e528b3 100644
--- a/java/org/apache/catalina/core/ApplicationMapping.java
+++ b/java/org/apache/catalina/core/ApplicationMapping.java
@@ -18,7 +18,6 @@ package org.apache.catalina.core;
 
 import org.apache.catalina.mapper.MappingData;
 import org.apache.catalina.servlet4preview.http.HttpServletMapping;
-import org.apache.catalina.servlet4preview.http.MappingMatch;
 
 public class ApplicationMapping {
 
@@ -36,7 +35,7 @@ public class ApplicationMapping {
                 // This can happen when dispatching from an application provided
                 // request object that does not provide the Servlet 4.0 mapping
                 // data.
-                mapping = new MappingImpl("", "", null, "");
+                mapping = new ApplicationMappingImpl("", "", null, "");
             } else {
                 String servletName;
                 if (mappingData.wrapper == null) {
@@ -45,23 +44,23 @@ public class ApplicationMapping {
                     servletName = mappingData.wrapper.getName();
                 }
                 if (mappingData.matchType == null) {
-                    mapping = new MappingImpl("", "", null, servletName);
+                    mapping = new ApplicationMappingImpl("", "", null, servletName);
                 } else {
                     switch (mappingData.matchType) {
                         case CONTEXT_ROOT:
-                            mapping = new MappingImpl("", "", mappingData.matchType, servletName);
+                            mapping = new ApplicationMappingImpl("", "", mappingData.matchType, servletName);
                             break;
                         case DEFAULT:
-                            mapping = new MappingImpl("", "/", mappingData.matchType, servletName);
+                            mapping = new ApplicationMappingImpl("", "/", mappingData.matchType, servletName);
                             break;
                         case EXACT:
-                            mapping = new MappingImpl(mappingData.wrapperPath.toString().substring(1),
+                            mapping = new ApplicationMappingImpl(mappingData.wrapperPath.toString().substring(1),
                                     mappingData.wrapperPath.toString(), mappingData.matchType, servletName);
                             break;
                         case EXTENSION:
                             String path = mappingData.wrapperPath.toString();
                             int extIndex = path.lastIndexOf('.');
-                            mapping = new MappingImpl(path.substring(1, extIndex),
+                            mapping = new ApplicationMappingImpl(path.substring(1, extIndex),
                                     "*" + path.substring(extIndex), mappingData.matchType, servletName);
                             break;
                         case PATH:
@@ -71,7 +70,7 @@ public class ApplicationMapping {
                             } else {
                                 matchValue = mappingData.pathInfo.toString().substring(1);
                             }
-                            mapping = new MappingImpl(matchValue, mappingData.wrapperPath.toString() + "/*",
+                            mapping = new ApplicationMappingImpl(matchValue, mappingData.wrapperPath.toString() + "/*",
                                     mappingData.matchType, servletName);
                             break;
                     }
@@ -85,40 +84,4 @@ public class ApplicationMapping {
     public void recycle() {
         mapping = null;
     }
-
-    private static class MappingImpl implements HttpServletMapping {
-
-        private final String matchValue;
-        private final String pattern;
-        private final MappingMatch mappingType;
-        private final String servletName;
-
-        public MappingImpl(String matchValue, String pattern, MappingMatch mappingType,
-                String servletName) {
-            this.matchValue = matchValue;
-            this.pattern = pattern;
-            this.mappingType = mappingType;
-            this.servletName = servletName;
-        }
-
-        @Override
-        public String getMatchValue() {
-            return matchValue;
-        }
-
-        @Override
-        public String getPattern() {
-            return pattern;
-        }
-
-        @Override
-        public MappingMatch getMappingMatch() {
-            return mappingType;
-        }
-
-        @Override
-        public String getServletName() {
-            return servletName;
-        }
-    }
 }
diff --git a/java/org/apache/catalina/core/ApplicationMappingImpl.java b/java/org/apache/catalina/core/ApplicationMappingImpl.java
new file mode 100644
index 0000000..e8d21c6
--- /dev/null
+++ b/java/org/apache/catalina/core/ApplicationMappingImpl.java
@@ -0,0 +1,39 @@
+package org.apache.catalina.core;
+
+import org.apache.catalina.servlet4preview.http.HttpServletMapping;
+import org.apache.catalina.servlet4preview.http.MappingMatch;
+
+public class ApplicationMappingImpl implements HttpServletMapping {
+
+    private final String matchValue;
+    private final String pattern;
+    private final MappingMatch mappingType;
+    private final String servletName;
+
+    public ApplicationMappingImpl(String matchValue, String pattern, MappingMatch mappingType, String servletName) {
+        this.matchValue = matchValue;
+        this.pattern = pattern;
+        this.mappingType = mappingType;
+        this.servletName = servletName;
+    }
+
+    @Override
+    public String getMatchValue() {
+        return matchValue;
+    }
+
+    @Override
+    public String getPattern() {
+        return pattern;
+    }
+
+    @Override
+    public MappingMatch getMappingMatch() {
+        return mappingType;
+    }
+
+    @Override
+    public String getServletName() {
+        return servletName;
+    }
+}


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


[tomcat] 03/04: Refactor: Remove HttpServletMapping interface

Posted by ma...@apache.org.
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

commit 1a87ea891530d2839586b3221d100bf741af1e20
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Fri Apr 3 16:59:55 2020 +0100

    Refactor: Remove HttpServletMapping interface
---
 java/org/apache/catalina/connector/Request.java    |  4 +-
 .../apache/catalina/connector/RequestFacade.java   |  4 +-
 .../apache/catalina/core/ApplicationContext.java   |  3 +-
 .../catalina/core/ApplicationDispatcher.java       |  9 ++--
 .../catalina/core/ApplicationHttpRequest.java      |  7 ++-
 .../apache/catalina/core/ApplicationMapping.java   |  5 +-
 .../catalina/core/ApplicationMappingImpl.java      | 12 ++---
 .../servlet4preview/http/HttpServletMapping.java   | 55 ----------------------
 .../servlet4preview/http/HttpServletRequest.java   |  4 +-
 .../http/HttpServletRequestWrapper.java            |  3 +-
 ...estApplicationContextGetRequestDispatcherB.java |  8 ++--
 .../catalina/core/TestApplicationMapping.java      |  9 ++--
 12 files changed, 31 insertions(+), 92 deletions(-)

diff --git a/java/org/apache/catalina/connector/Request.java b/java/org/apache/catalina/connector/Request.java
index dbc2c16..71a107d 100644
--- a/java/org/apache/catalina/connector/Request.java
+++ b/java/org/apache/catalina/connector/Request.java
@@ -77,12 +77,12 @@ import org.apache.catalina.TomcatPrincipal;
 import org.apache.catalina.Wrapper;
 import org.apache.catalina.core.ApplicationFilterChain;
 import org.apache.catalina.core.ApplicationMapping;
+import org.apache.catalina.core.ApplicationMappingImpl;
 import org.apache.catalina.core.ApplicationPart;
 import org.apache.catalina.core.ApplicationPushBuilder;
 import org.apache.catalina.core.ApplicationSessionCookieConfig;
 import org.apache.catalina.core.AsyncContextImpl;
 import org.apache.catalina.mapper.MappingData;
-import org.apache.catalina.servlet4preview.http.HttpServletMapping;
 import org.apache.catalina.session.ManagerBase;
 import org.apache.catalina.util.ParameterMap;
 import org.apache.catalina.util.TLSUtil;
@@ -2304,7 +2304,7 @@ public class Request implements org.apache.catalina.servlet4preview.http.HttpSer
 
 
     @Override
-    public HttpServletMapping getHttpServletMapping() {
+    public ApplicationMappingImpl getHttpServletMapping() {
         return applicationMapping.getHttpServletMapping();
     }
 
diff --git a/java/org/apache/catalina/connector/RequestFacade.java b/java/org/apache/catalina/connector/RequestFacade.java
index 41d0dde..3ecf5b9 100644
--- a/java/org/apache/catalina/connector/RequestFacade.java
+++ b/java/org/apache/catalina/connector/RequestFacade.java
@@ -40,9 +40,9 @@ import javax.servlet.http.HttpUpgradeHandler;
 import javax.servlet.http.Part;
 
 import org.apache.catalina.Globals;
+import org.apache.catalina.core.ApplicationMappingImpl;
 import org.apache.catalina.core.ApplicationPushBuilder;
 import org.apache.catalina.security.SecurityUtil;
-import org.apache.catalina.servlet4preview.http.HttpServletMapping;
 import org.apache.catalina.servlet4preview.http.HttpServletRequest;
 import org.apache.tomcat.util.res.StringManager;
 
@@ -1123,7 +1123,7 @@ public class RequestFacade implements HttpServletRequest {
      * removed or replaced at any time until Servlet 4.0 becomes final.
      */
     @Override
-    public HttpServletMapping getHttpServletMapping() {
+    public ApplicationMappingImpl getHttpServletMapping() {
         return request.getHttpServletMapping();
     }
 
diff --git a/java/org/apache/catalina/core/ApplicationContext.java b/java/org/apache/catalina/core/ApplicationContext.java
index d44ef02..8a42c24 100644
--- a/java/org/apache/catalina/core/ApplicationContext.java
+++ b/java/org/apache/catalina/core/ApplicationContext.java
@@ -67,7 +67,6 @@ import org.apache.catalina.WebResourceRoot;
 import org.apache.catalina.Wrapper;
 import org.apache.catalina.connector.Connector;
 import org.apache.catalina.mapper.MappingData;
-import org.apache.catalina.servlet4preview.http.HttpServletMapping;
 import org.apache.catalina.util.Introspection;
 import org.apache.catalina.util.ServerInfo;
 import org.apache.catalina.util.URLEncoder;
@@ -482,7 +481,7 @@ public class ApplicationContext implements ServletContext {
             Wrapper wrapper = mappingData.wrapper;
             String wrapperPath = mappingData.wrapperPath.toString();
             String pathInfo = mappingData.pathInfo.toString();
-            HttpServletMapping mapping = new ApplicationMapping(mappingData).getHttpServletMapping();
+            ApplicationMappingImpl mapping = new ApplicationMapping(mappingData).getHttpServletMapping();
 
             // Construct a RequestDispatcher to process this request
             return new ApplicationDispatcher(wrapper, uri, wrapperPath, pathInfo,
diff --git a/java/org/apache/catalina/core/ApplicationDispatcher.java b/java/org/apache/catalina/core/ApplicationDispatcher.java
index 1f93011..eb3d420 100644
--- a/java/org/apache/catalina/core/ApplicationDispatcher.java
+++ b/java/org/apache/catalina/core/ApplicationDispatcher.java
@@ -44,7 +44,6 @@ import org.apache.catalina.connector.Request;
 import org.apache.catalina.connector.RequestFacade;
 import org.apache.catalina.connector.Response;
 import org.apache.catalina.connector.ResponseFacade;
-import org.apache.catalina.servlet4preview.http.HttpServletMapping;
 import org.apache.tomcat.util.ExceptionUtils;
 import org.apache.tomcat.util.res.StringManager;
 
@@ -211,7 +210,7 @@ final class ApplicationDispatcher implements AsyncDispatcher, RequestDispatcher
      */
     public ApplicationDispatcher
         (Wrapper wrapper, String requestURI, String servletPath,
-         String pathInfo, String queryString, HttpServletMapping mapping, String name) {
+         String pathInfo, String queryString, ApplicationMappingImpl mapping, String name) {
 
         super();
 
@@ -268,7 +267,7 @@ final class ApplicationDispatcher implements AsyncDispatcher, RequestDispatcher
     /**
      * The mapping for this RequestDispatcher.
      */
-    private final HttpServletMapping mapping;
+    private final ApplicationMappingImpl mapping;
 
 
     /**
@@ -372,7 +371,7 @@ final class ApplicationDispatcher implements AsyncDispatcher, RequestDispatcher
                                       hrequest.getPathInfo());
                 wrequest.setAttribute(RequestDispatcher.FORWARD_QUERY_STRING,
                                       hrequest.getQueryString());
-                HttpServletMapping mapping;
+                ApplicationMappingImpl mapping;
                 if (hrequest instanceof org.apache.catalina.servlet4preview.http.HttpServletRequest) {
                     mapping = ((org.apache.catalina.servlet4preview.http.HttpServletRequest)
                             hrequest).getHttpServletMapping();
@@ -627,7 +626,7 @@ final class ApplicationDispatcher implements AsyncDispatcher, RequestDispatcher
 
         wrequest.setAttribute(Globals.DISPATCHER_TYPE_ATTR, DispatcherType.ASYNC);
         wrequest.setAttribute(Globals.DISPATCHER_REQUEST_PATH_ATTR, getCombinedPath());
-        HttpServletMapping mapping;
+        ApplicationMappingImpl mapping;
         if (hrequest instanceof org.apache.catalina.servlet4preview.http.HttpServletRequest) {
             mapping = ((org.apache.catalina.servlet4preview.http.HttpServletRequest)
                     hrequest).getHttpServletMapping();
diff --git a/java/org/apache/catalina/core/ApplicationHttpRequest.java b/java/org/apache/catalina/core/ApplicationHttpRequest.java
index 2bb795c..fab0799 100644
--- a/java/org/apache/catalina/core/ApplicationHttpRequest.java
+++ b/java/org/apache/catalina/core/ApplicationHttpRequest.java
@@ -42,7 +42,6 @@ import org.apache.catalina.Globals;
 import org.apache.catalina.Manager;
 import org.apache.catalina.Session;
 import org.apache.catalina.connector.RequestFacade;
-import org.apache.catalina.servlet4preview.http.HttpServletMapping;
 import org.apache.catalina.util.ParameterMap;
 import org.apache.catalina.util.URLEncoder;
 import org.apache.tomcat.util.buf.B2CConverter;
@@ -193,7 +192,7 @@ class ApplicationHttpRequest
     /**
      * The mapping for this request.
      */
-    private HttpServletMapping mapping = null;
+    private ApplicationMappingImpl mapping = null;
 
 
     /**
@@ -528,7 +527,7 @@ class ApplicationHttpRequest
 
 
     @Override
-    public HttpServletMapping getHttpServletMapping() {
+    public ApplicationMappingImpl getHttpServletMapping() {
         return mapping;
     }
 
@@ -781,7 +780,7 @@ class ApplicationHttpRequest
     }
 
 
-    void setMapping(HttpServletMapping mapping) {
+    void setMapping(ApplicationMappingImpl mapping) {
         this.mapping = mapping;
     }
 
diff --git a/java/org/apache/catalina/core/ApplicationMapping.java b/java/org/apache/catalina/core/ApplicationMapping.java
index 9e528b3..0c988cf 100644
--- a/java/org/apache/catalina/core/ApplicationMapping.java
+++ b/java/org/apache/catalina/core/ApplicationMapping.java
@@ -17,19 +17,18 @@
 package org.apache.catalina.core;
 
 import org.apache.catalina.mapper.MappingData;
-import org.apache.catalina.servlet4preview.http.HttpServletMapping;
 
 public class ApplicationMapping {
 
     private final MappingData mappingData;
 
-    private volatile HttpServletMapping mapping = null;
+    private volatile ApplicationMappingImpl mapping = null;
 
     public ApplicationMapping(MappingData mappingData) {
         this.mappingData = mappingData;
     }
 
-    public HttpServletMapping getHttpServletMapping() {
+    public ApplicationMappingImpl getHttpServletMapping() {
         if (mapping == null) {
             if (mappingData == null) {
                 // This can happen when dispatching from an application provided
diff --git a/java/org/apache/catalina/core/ApplicationMappingImpl.java b/java/org/apache/catalina/core/ApplicationMappingImpl.java
index cf64d24..2362b1f 100644
--- a/java/org/apache/catalina/core/ApplicationMappingImpl.java
+++ b/java/org/apache/catalina/core/ApplicationMappingImpl.java
@@ -1,8 +1,6 @@
 package org.apache.catalina.core;
 
-import org.apache.catalina.servlet4preview.http.HttpServletMapping;
-
-public class ApplicationMappingImpl implements HttpServletMapping {
+public class ApplicationMappingImpl {
 
     private final String matchValue;
     private final String pattern;
@@ -16,22 +14,22 @@ public class ApplicationMappingImpl implements HttpServletMapping {
         this.servletName = servletName;
     }
 
-    @Override
+
     public String getMatchValue() {
         return matchValue;
     }
 
-    @Override
+
     public String getPattern() {
         return pattern;
     }
 
-    @Override
+
     public ApplicationMappingMatch getMappingMatch() {
         return mappingType;
     }
 
-    @Override
+
     public String getServletName() {
         return servletName;
     }
diff --git a/java/org/apache/catalina/servlet4preview/http/HttpServletMapping.java b/java/org/apache/catalina/servlet4preview/http/HttpServletMapping.java
deleted file mode 100644
index cad96e1..0000000
--- a/java/org/apache/catalina/servlet4preview/http/HttpServletMapping.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
-* Licensed to the Apache Software Foundation (ASF) under one or more
-* contributor license agreements.  See the NOTICE file distributed with
-* this work for additional information regarding copyright ownership.
-* The ASF licenses this file to You under the Apache License, Version 2.0
-* (the "License"); you may not use this file except in compliance with
-* the License.  You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package org.apache.catalina.servlet4preview.http;
-
-import javax.servlet.annotation.WebServlet;
-
-import org.apache.catalina.core.ApplicationMappingMatch;
-
-/**
- * Represents how the request from which this object was obtained was mapped to
- * the associated servlet.
- *
- * @since 4.0
- */
-public interface HttpServletMapping {
-
-    /**
-     * @return The value that was matched or the empty String if not known.
-     */
-    String getMatchValue();
-
-    /**
-     * @return The {@code url-pattern} that matched this request or the empty
-     *         String if not known.
-     */
-    String getPattern();
-
-    /**
-     * @return The name of the servlet (as specified in web.xml,
-     *         {@link WebServlet#name()},
-     *         {@link javax.servlet.ServletContext#addServlet(String, Class)} or
-     *         one of the other <code>addServlet()</code> methods) that the
-     *         request was mapped to.
-     */
-    String getServletName();
-
-    /**
-     * @return The type of match ({@code null} if not known)
-     */
-    ApplicationMappingMatch getMappingMatch();
-}
diff --git a/java/org/apache/catalina/servlet4preview/http/HttpServletRequest.java b/java/org/apache/catalina/servlet4preview/http/HttpServletRequest.java
index 64ac62b..f605ed7 100644
--- a/java/org/apache/catalina/servlet4preview/http/HttpServletRequest.java
+++ b/java/org/apache/catalina/servlet4preview/http/HttpServletRequest.java
@@ -16,10 +16,12 @@
  */
 package org.apache.catalina.servlet4preview.http;
 
+import org.apache.catalina.core.ApplicationMappingImpl;
+
 /**
  * Provides early access to some parts of the Servlet 4.0 API.
  */
 public interface HttpServletRequest extends javax.servlet.http.HttpServletRequest {
 
-    public HttpServletMapping getHttpServletMapping();
+    public ApplicationMappingImpl getHttpServletMapping();
 }
diff --git a/java/org/apache/catalina/servlet4preview/http/HttpServletRequestWrapper.java b/java/org/apache/catalina/servlet4preview/http/HttpServletRequestWrapper.java
index 67b6efa..7ed31ce 100644
--- a/java/org/apache/catalina/servlet4preview/http/HttpServletRequestWrapper.java
+++ b/java/org/apache/catalina/servlet4preview/http/HttpServletRequestWrapper.java
@@ -16,6 +16,7 @@
  */
 package org.apache.catalina.servlet4preview.http;
 
+import org.apache.catalina.core.ApplicationMappingImpl;
 
 /**
  * Provides early access to some parts of the Servlet 4.0 API.
@@ -47,7 +48,7 @@ public class HttpServletRequestWrapper extends javax.servlet.http.HttpServletReq
      * @since Servlet 4.0
      */
     @Override
-    public HttpServletMapping getHttpServletMapping() {
+    public ApplicationMappingImpl getHttpServletMapping() {
         return this._getHttpServletRequest().getHttpServletMapping();
     }
 }
diff --git a/test/org/apache/catalina/core/TestApplicationContextGetRequestDispatcherB.java b/test/org/apache/catalina/core/TestApplicationContextGetRequestDispatcherB.java
index be1b8a4..8bcbcde 100755
--- a/test/org/apache/catalina/core/TestApplicationContextGetRequestDispatcherB.java
+++ b/test/org/apache/catalina/core/TestApplicationContextGetRequestDispatcherB.java
@@ -38,7 +38,6 @@ import org.junit.runners.Parameterized.Parameters;
 
 import org.apache.catalina.Context;
 import org.apache.catalina.Wrapper;
-import org.apache.catalina.servlet4preview.http.HttpServletMapping;
 import org.apache.catalina.startup.Tomcat;
 import org.apache.catalina.startup.TomcatBaseTest;
 import org.apache.tomcat.util.buf.ByteChunk;
@@ -527,7 +526,7 @@ public class TestApplicationContextGetRequestDispatcherB extends TomcatBaseTest
             Assert.assertEquals(expectedServletPath, req.getServletPath());
             Assert.assertEquals(expectedPathInfo, req.getPathInfo());
             Assert.assertEquals(expectedQueryString, req.getQueryString());
-            HttpServletMapping mapping =
+            ApplicationMappingImpl mapping =
                     ((org.apache.catalina.servlet4preview.http.HttpServletRequest) req).getHttpServletMapping();
             Assert.assertEquals(expectedMappingMatch, mapping.getMappingMatch());
             Assert.assertEquals(expectedMappingPattern, mapping.getPattern());
@@ -547,9 +546,8 @@ public class TestApplicationContextGetRequestDispatcherB extends TomcatBaseTest
                             req.getAttribute("javax.servlet." + name + ".path_info"));
                     Assert.assertEquals(expectedDispatcherQueryString,
                             req.getAttribute("javax.servlet." + name + ".query_string"));
-                    HttpServletMapping dispatcherMapping =
-                            (HttpServletMapping) ((org.apache.catalina.servlet4preview.http.HttpServletRequest) req).getAttribute(
-                                    "javax.servlet." + name + ".mapping");
+                    ApplicationMappingImpl dispatcherMapping =
+                            (ApplicationMappingImpl) req.getAttribute("javax.servlet." + name + ".mapping");
                     Assert.assertNotNull(dispatcherMapping);
                     Assert.assertEquals(expectedDispatcherMappingMatch,
                             dispatcherMapping.getMappingMatch());
diff --git a/test/org/apache/catalina/core/TestApplicationMapping.java b/test/org/apache/catalina/core/TestApplicationMapping.java
index 2cb9d1b..76ef88c 100644
--- a/test/org/apache/catalina/core/TestApplicationMapping.java
+++ b/test/org/apache/catalina/core/TestApplicationMapping.java
@@ -31,7 +31,6 @@ import org.junit.Test;
 
 import org.apache.catalina.Context;
 import org.apache.catalina.Wrapper;
-import org.apache.catalina.servlet4preview.http.HttpServletMapping;
 import org.apache.catalina.startup.Tomcat;
 import org.apache.catalina.startup.TomcatBaseTest;
 import org.apache.tomcat.util.buf.ByteChunk;
@@ -340,13 +339,13 @@ public class TestApplicationMapping extends TomcatBaseTest {
                 throws ServletException, IOException {
             resp.setContentType("text/plain;charset=UTF-8");
             PrintWriter pw = resp.getWriter();
-            HttpServletMapping mapping = ((org.apache.catalina.servlet4preview.http.HttpServletRequest)
+            ApplicationMappingImpl mapping = ((org.apache.catalina.servlet4preview.http.HttpServletRequest)
                     req).getHttpServletMapping();
             pw.println("MatchValue=[" + mapping.getMatchValue() + "]");
             pw.println("Pattern=[" + mapping.getPattern() + "]");
             pw.println("MatchType=[" + mapping.getMappingMatch() + "]");
             pw.println("ServletName=[" + mapping.getServletName() + "]");
-            HttpServletMapping includeMapping = (HttpServletMapping) req.getAttribute(
+            ApplicationMappingImpl includeMapping = (ApplicationMappingImpl) req.getAttribute(
                     ApplicationDispatcher.INCLUDE_MAPPING);
             if (includeMapping != null) {
                 pw.println("IncludeMatchValue=[" + includeMapping.getMatchValue() + "]");
@@ -355,7 +354,7 @@ public class TestApplicationMapping extends TomcatBaseTest {
                 pw.println("IncludeServletName=[" + includeMapping.getServletName() + "]");
 
             }
-            HttpServletMapping forwardMapping = (HttpServletMapping) req.getAttribute(
+            ApplicationMappingImpl forwardMapping = (ApplicationMappingImpl) req.getAttribute(
                     ApplicationDispatcher.FORWARD_MAPPING);
             if (forwardMapping != null) {
                 pw.println("ForwardMatchValue=[" + forwardMapping.getMatchValue() + "]");
@@ -363,7 +362,7 @@ public class TestApplicationMapping extends TomcatBaseTest {
                 pw.println("ForwardMatchType=[" + forwardMapping.getMappingMatch() + "]");
                 pw.println("ForwardServletName=[" + forwardMapping.getServletName() + "]");
             }
-            HttpServletMapping asyncMapping = (HttpServletMapping) req.getAttribute(
+            ApplicationMappingImpl asyncMapping = (ApplicationMappingImpl) req.getAttribute(
                     ApplicationDispatcher.ASYNC_MAPPING);
             if (asyncMapping != null) {
                 pw.println("AsyncMatchValue=[" + asyncMapping.getMatchValue() + "]");


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


[tomcat] 04/04: Refactoring: Remove remainder of servlet4preview package

Posted by ma...@apache.org.
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

commit 0be3e38a07ceb1c75e568915bef496f63edbc9b6
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Fri Apr 3 17:23:53 2020 +0100

    Refactoring: Remove remainder of servlet4preview package
    
    The functionality remains but requires casting to the appropriate
    internal Tomcat class.
---
 java/org/apache/catalina/connector/Request.java    |  3 +-
 .../apache/catalina/connector/RequestFacade.java   |  9 +---
 .../catalina/core/ApplicationDispatcher.java       | 18 +-------
 .../catalina/core/ApplicationHttpRequest.java      | 11 ++---
 .../apache/catalina/core/ApplicationMapping.java   | 25 ++++++++++
 .../catalina/core/ApplicationMappingImpl.java      | 16 +++++++
 .../org/apache/catalina/filters/ExpiresFilter.java | 28 ++++++-----
 .../servlet4preview/http/HttpServletRequest.java   | 27 -----------
 .../http/HttpServletRequestWrapper.java            | 54 ----------------------
 ...estApplicationContextGetRequestDispatcherB.java |  3 +-
 .../catalina/core/TestApplicationMapping.java      |  3 +-
 webapps/docs/changelog.xml                         | 10 ++++
 12 files changed, 73 insertions(+), 134 deletions(-)

diff --git a/java/org/apache/catalina/connector/Request.java b/java/org/apache/catalina/connector/Request.java
index 71a107d..301d5a9 100644
--- a/java/org/apache/catalina/connector/Request.java
+++ b/java/org/apache/catalina/connector/Request.java
@@ -125,7 +125,7 @@ import org.ietf.jgss.GSSException;
  * @author Remy Maucherat
  * @author Craig R. McClanahan
  */
-public class Request implements org.apache.catalina.servlet4preview.http.HttpServletRequest {
+public class Request implements HttpServletRequest {
 
     private static final Log log = LogFactory.getLog(Request.class);
 
@@ -2303,7 +2303,6 @@ public class Request implements org.apache.catalina.servlet4preview.http.HttpSer
     }
 
 
-    @Override
     public ApplicationMappingImpl getHttpServletMapping() {
         return applicationMapping.getHttpServletMapping();
     }
diff --git a/java/org/apache/catalina/connector/RequestFacade.java b/java/org/apache/catalina/connector/RequestFacade.java
index 3ecf5b9..e80147c 100644
--- a/java/org/apache/catalina/connector/RequestFacade.java
+++ b/java/org/apache/catalina/connector/RequestFacade.java
@@ -34,6 +34,7 @@ import javax.servlet.ServletInputStream;
 import javax.servlet.ServletRequest;
 import javax.servlet.ServletResponse;
 import javax.servlet.http.Cookie;
+import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import javax.servlet.http.HttpSession;
 import javax.servlet.http.HttpUpgradeHandler;
@@ -43,7 +44,6 @@ import org.apache.catalina.Globals;
 import org.apache.catalina.core.ApplicationMappingImpl;
 import org.apache.catalina.core.ApplicationPushBuilder;
 import org.apache.catalina.security.SecurityUtil;
-import org.apache.catalina.servlet4preview.http.HttpServletRequest;
 import org.apache.tomcat.util.res.StringManager;
 
 /**
@@ -1116,13 +1116,6 @@ public class RequestFacade implements HttpServletRequest {
     }
 
 
-    /**
-     * {@inheritDoc}
-     * <p>
-     * Pulled forward from Servlet 4.0. The method signature may be modified,
-     * removed or replaced at any time until Servlet 4.0 becomes final.
-     */
-    @Override
     public ApplicationMappingImpl getHttpServletMapping() {
         return request.getHttpServletMapping();
     }
diff --git a/java/org/apache/catalina/core/ApplicationDispatcher.java b/java/org/apache/catalina/core/ApplicationDispatcher.java
index eb3d420..c32a78e 100644
--- a/java/org/apache/catalina/core/ApplicationDispatcher.java
+++ b/java/org/apache/catalina/core/ApplicationDispatcher.java
@@ -371,14 +371,7 @@ final class ApplicationDispatcher implements AsyncDispatcher, RequestDispatcher
                                       hrequest.getPathInfo());
                 wrequest.setAttribute(RequestDispatcher.FORWARD_QUERY_STRING,
                                       hrequest.getQueryString());
-                ApplicationMappingImpl mapping;
-                if (hrequest instanceof org.apache.catalina.servlet4preview.http.HttpServletRequest) {
-                    mapping = ((org.apache.catalina.servlet4preview.http.HttpServletRequest)
-                            hrequest).getHttpServletMapping();
-                } else {
-                    mapping = (new ApplicationMapping(null)).getHttpServletMapping();
-                }
-                wrequest.setAttribute(FORWARD_MAPPING, mapping);
+                wrequest.setAttribute(FORWARD_MAPPING, ApplicationMapping.getHttpServletMapping(hrequest));
             }
 
             wrequest.setContextPath(context.getEncodedPath());
@@ -626,14 +619,7 @@ final class ApplicationDispatcher implements AsyncDispatcher, RequestDispatcher
 
         wrequest.setAttribute(Globals.DISPATCHER_TYPE_ATTR, DispatcherType.ASYNC);
         wrequest.setAttribute(Globals.DISPATCHER_REQUEST_PATH_ATTR, getCombinedPath());
-        ApplicationMappingImpl mapping;
-        if (hrequest instanceof org.apache.catalina.servlet4preview.http.HttpServletRequest) {
-            mapping = ((org.apache.catalina.servlet4preview.http.HttpServletRequest)
-                    hrequest).getHttpServletMapping();
-        } else {
-            mapping = (new ApplicationMapping(null)).getHttpServletMapping();
-        }
-        wrequest.setAttribute(ASYNC_MAPPING, mapping);
+        wrequest.setAttribute(ASYNC_MAPPING, ApplicationMapping.getHttpServletMapping(hrequest));
 
         wrequest.setContextPath(context.getEncodedPath());
         wrequest.setRequestURI(requestURI);
diff --git a/java/org/apache/catalina/core/ApplicationHttpRequest.java b/java/org/apache/catalina/core/ApplicationHttpRequest.java
index fab0799..bd27924 100644
--- a/java/org/apache/catalina/core/ApplicationHttpRequest.java
+++ b/java/org/apache/catalina/core/ApplicationHttpRequest.java
@@ -35,6 +35,7 @@ import javax.servlet.ServletContext;
 import javax.servlet.ServletRequest;
 import javax.servlet.ServletRequestWrapper;
 import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletRequestWrapper;
 import javax.servlet.http.HttpSession;
 
 import org.apache.catalina.Context;
@@ -65,8 +66,7 @@ import org.apache.tomcat.util.res.StringManager;
  * @author Craig R. McClanahan
  * @author Remy Maucherat
  */
-class ApplicationHttpRequest
-        extends org.apache.catalina.servlet4preview.http.HttpServletRequestWrapper {
+class ApplicationHttpRequest extends HttpServletRequestWrapper {
 
     private static final StringManager sm = StringManager.getManager(ApplicationHttpRequest.class);
 
@@ -526,7 +526,6 @@ class ApplicationHttpRequest
     }
 
 
-    @Override
     public ApplicationMappingImpl getHttpServletMapping() {
         return mapping;
     }
@@ -717,11 +716,7 @@ class ApplicationHttpRequest
         queryString = request.getQueryString();
         requestURI = request.getRequestURI();
         servletPath = request.getServletPath();
-        if (request instanceof org.apache.catalina.servlet4preview.http.HttpServletRequest) {
-            mapping = ((org.apache.catalina.servlet4preview.http.HttpServletRequest) request).getHttpServletMapping();
-        } else {
-            mapping = (new ApplicationMapping(null)).getHttpServletMapping();
-        }
+        mapping = ApplicationMapping.getHttpServletMapping(request);
     }
 
 
diff --git a/java/org/apache/catalina/core/ApplicationMapping.java b/java/org/apache/catalina/core/ApplicationMapping.java
index 0c988cf..39ce111 100644
--- a/java/org/apache/catalina/core/ApplicationMapping.java
+++ b/java/org/apache/catalina/core/ApplicationMapping.java
@@ -16,6 +16,11 @@
  */
 package org.apache.catalina.core;
 
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletRequestWrapper;
+
+import org.apache.catalina.connector.Request;
+import org.apache.catalina.connector.RequestFacade;
 import org.apache.catalina.mapper.MappingData;
 
 public class ApplicationMapping {
@@ -83,4 +88,24 @@ public class ApplicationMapping {
     public void recycle() {
         mapping = null;
     }
+
+
+    public static ApplicationMappingImpl getHttpServletMapping(HttpServletRequest request) {
+        if (request instanceof RequestFacade) {
+            return ((RequestFacade) request).getHttpServletMapping();
+        } else if (request instanceof Request) {
+            return ((Request) request).getHttpServletMapping();
+        } else if (request instanceof ApplicationHttpRequest) {
+            return ((ApplicationHttpRequest) request).getHttpServletMapping();
+        }
+        return (new ApplicationMapping(null)).getHttpServletMapping();
+    }
+
+
+    public static ApplicationMappingImpl getHttpServletMapping(HttpServletRequestWrapper wrapper) {
+        if (wrapper instanceof ApplicationHttpRequest) {
+            return ((ApplicationHttpRequest) wrapper).getHttpServletMapping();
+        }
+        return (new ApplicationMapping(null)).getHttpServletMapping();
+    }
 }
diff --git a/java/org/apache/catalina/core/ApplicationMappingImpl.java b/java/org/apache/catalina/core/ApplicationMappingImpl.java
index 2362b1f..3922943 100644
--- a/java/org/apache/catalina/core/ApplicationMappingImpl.java
+++ b/java/org/apache/catalina/core/ApplicationMappingImpl.java
@@ -1,3 +1,19 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 package org.apache.catalina.core;
 
 public class ApplicationMappingImpl {
diff --git a/java/org/apache/catalina/filters/ExpiresFilter.java b/java/org/apache/catalina/filters/ExpiresFilter.java
index 6c7ff78..66b21cf 100644
--- a/java/org/apache/catalina/filters/ExpiresFilter.java
+++ b/java/org/apache/catalina/filters/ExpiresFilter.java
@@ -42,6 +42,8 @@ import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import javax.servlet.http.HttpServletResponseWrapper;
 
+import org.apache.catalina.core.ApplicationMapping;
+import org.apache.catalina.core.ApplicationMappingImpl;
 import org.apache.catalina.core.ApplicationMappingMatch;
 import org.apache.juli.logging.Log;
 import org.apache.juli.logging.LogFactory;
@@ -1292,21 +1294,17 @@ public class ExpiresFilter extends FilterBase {
                 innerRequest = ((ServletRequestWrapper) innerRequest).getRequest();
             }
 
-            if (innerRequest instanceof org.apache.catalina.servlet4preview.http.HttpServletRequest) {
-                org.apache.catalina.servlet4preview.http.HttpServletRequest servlet4Request =
-                        (org.apache.catalina.servlet4preview.http.HttpServletRequest) innerRequest;
-
-                if (servlet4Request.getHttpServletMapping().getMappingMatch() == ApplicationMappingMatch.DEFAULT &&
-                        response.getStatus() == HttpServletResponse.SC_NOT_MODIFIED) {
-                    // Default servlet normally sets the content type but does not for
-                    // 304 responses. Look it up.
-                    String servletPath = request.getServletPath();
-                    if (servletPath != null) {
-                        int lastSlash = servletPath.lastIndexOf('/');
-                        if (lastSlash > -1) {
-                            String fileName = servletPath.substring(lastSlash + 1);
-                            contentType = request.getServletContext().getMimeType(fileName);
-                        }
+            ApplicationMappingImpl mapping = ApplicationMapping.getHttpServletMapping(request);
+            if (mapping.getMappingMatch() == ApplicationMappingMatch.DEFAULT &&
+                    response.getStatus() == HttpServletResponse.SC_NOT_MODIFIED) {
+                // Default servlet normally sets the content type but does not for
+                // 304 responses. Look it up.
+                String servletPath = request.getServletPath();
+                if (servletPath != null) {
+                    int lastSlash = servletPath.lastIndexOf('/');
+                    if (lastSlash > -1) {
+                        String fileName = servletPath.substring(lastSlash + 1);
+                        contentType = request.getServletContext().getMimeType(fileName);
                     }
                 }
             }
diff --git a/java/org/apache/catalina/servlet4preview/http/HttpServletRequest.java b/java/org/apache/catalina/servlet4preview/http/HttpServletRequest.java
deleted file mode 100644
index f605ed7..0000000
--- a/java/org/apache/catalina/servlet4preview/http/HttpServletRequest.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.catalina.servlet4preview.http;
-
-import org.apache.catalina.core.ApplicationMappingImpl;
-
-/**
- * Provides early access to some parts of the Servlet 4.0 API.
- */
-public interface HttpServletRequest extends javax.servlet.http.HttpServletRequest {
-
-    public ApplicationMappingImpl getHttpServletMapping();
-}
diff --git a/java/org/apache/catalina/servlet4preview/http/HttpServletRequestWrapper.java b/java/org/apache/catalina/servlet4preview/http/HttpServletRequestWrapper.java
deleted file mode 100644
index 7ed31ce..0000000
--- a/java/org/apache/catalina/servlet4preview/http/HttpServletRequestWrapper.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.catalina.servlet4preview.http;
-
-import org.apache.catalina.core.ApplicationMappingImpl;
-
-/**
- * Provides early access to some parts of the Servlet 4.0 API.
- */
-public class HttpServletRequestWrapper extends javax.servlet.http.HttpServletRequestWrapper
-        implements HttpServletRequest {
-
-    /**
-     * Constructs a request object wrapping the given request.
-     *
-     * @param request The request to wrap
-     *
-     * @throws java.lang.IllegalArgumentException
-     *             if the request is null
-     */
-    public HttpServletRequestWrapper(javax.servlet.http.HttpServletRequest request) {
-        super(request);
-    }
-
-    private HttpServletRequest _getHttpServletRequest() {
-        return (HttpServletRequest) super.getRequest();
-    }
-
-    /**
-     * The default behavior of this method is to return
-     * {@link HttpServletRequest#getHttpServletMapping()} on the wrapped request
-     * object.
-     *
-     * @since Servlet 4.0
-     */
-    @Override
-    public ApplicationMappingImpl getHttpServletMapping() {
-        return this._getHttpServletRequest().getHttpServletMapping();
-    }
-}
diff --git a/test/org/apache/catalina/core/TestApplicationContextGetRequestDispatcherB.java b/test/org/apache/catalina/core/TestApplicationContextGetRequestDispatcherB.java
index 8bcbcde..f2e7f5e 100755
--- a/test/org/apache/catalina/core/TestApplicationContextGetRequestDispatcherB.java
+++ b/test/org/apache/catalina/core/TestApplicationContextGetRequestDispatcherB.java
@@ -526,8 +526,7 @@ public class TestApplicationContextGetRequestDispatcherB extends TomcatBaseTest
             Assert.assertEquals(expectedServletPath, req.getServletPath());
             Assert.assertEquals(expectedPathInfo, req.getPathInfo());
             Assert.assertEquals(expectedQueryString, req.getQueryString());
-            ApplicationMappingImpl mapping =
-                    ((org.apache.catalina.servlet4preview.http.HttpServletRequest) req).getHttpServletMapping();
+            ApplicationMappingImpl mapping = ApplicationMapping.getHttpServletMapping(req);
             Assert.assertEquals(expectedMappingMatch, mapping.getMappingMatch());
             Assert.assertEquals(expectedMappingPattern, mapping.getPattern());
             Assert.assertEquals(expectedMappingMatchValue, mapping.getMatchValue());
diff --git a/test/org/apache/catalina/core/TestApplicationMapping.java b/test/org/apache/catalina/core/TestApplicationMapping.java
index 76ef88c..7636a3a 100644
--- a/test/org/apache/catalina/core/TestApplicationMapping.java
+++ b/test/org/apache/catalina/core/TestApplicationMapping.java
@@ -339,8 +339,7 @@ public class TestApplicationMapping extends TomcatBaseTest {
                 throws ServletException, IOException {
             resp.setContentType("text/plain;charset=UTF-8");
             PrintWriter pw = resp.getWriter();
-            ApplicationMappingImpl mapping = ((org.apache.catalina.servlet4preview.http.HttpServletRequest)
-                    req).getHttpServletMapping();
+            ApplicationMappingImpl mapping = ApplicationMapping.getHttpServletMapping(req);
             pw.println("MatchValue=[" + mapping.getMatchValue() + "]");
             pw.println("Pattern=[" + mapping.getPattern() + "]");
             pw.println("MatchType=[" + mapping.getMappingMatch() + "]");
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index c4b0f93..7ad9daf 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -45,6 +45,16 @@
   issues do not "pop up" wrt. others).
 -->
 <section name="Tomcat 8.5.55 (markt)" rtext="in development">
+  <subsection name="Catalina">
+    <changelog>
+      <scode>
+        Remove the remainder of the deprecated Servlet 4 Preview API. Users
+        still depending on this feature should ideally upgrade to Tomcat
+        9.0.x. If upgrade is not possible, application code should cast to the
+        internal Tomcat implementation classes. (markt)
+      </scode>
+    </changelog>
+  </subsection>
 </section>
 <section name="Tomcat 8.5.54 (markt)" rtext="release in progress">
   <subsection name="Catalina">


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