MCPcopy Index your code
hub / github.com/apache/tomcat / internalMapWrapper

Method internalMapWrapper

java/org/apache/catalina/mapper/Mapper.java:853–1024  ·  view source on GitHub ↗

Wrapper mapping. @throws IOException if the buffers are too small to hold the results of the mapping.

(ContextVersion contextVersion, CharChunk path, MappingData mappingData)

Source from the content-addressed store, hash-verified

851 * @throws IOException if the buffers are too small to hold the results of the mapping.
852 */
853 private void internalMapWrapper(ContextVersion contextVersion, CharChunk path, MappingData mappingData)
854 throws IOException {
855
856 int pathStart = path.getStart();
857 int pathEnd = path.getEnd();
858 boolean noServletPath = false;
859
860 int length = contextVersion.path.length();
861 if (length == (pathEnd - pathStart)) {
862 noServletPath = true;
863 }
864 int servletPath = pathStart + length;
865 path.setStart(servletPath);
866
867 // Rule 1 -- Exact Match
868 MappedWrapper[] exactWrappers = contextVersion.exactWrappers;
869 internalMapExactWrapper(exactWrappers, path, mappingData);
870
871 // Rule 2 -- Prefix Match
872 boolean checkJspWelcomeFiles = false;
873 MappedWrapper[] wildcardWrappers = contextVersion.wildcardWrappers;
874 if (mappingData.wrapper == null) {
875 internalMapWildcardWrapper(wildcardWrappers, contextVersion.nesting, path, mappingData);
876 if (mappingData.wrapper != null && mappingData.jspWildCard) {
877 char[] buf = path.getBuffer();
878 if (buf[pathEnd - 1] == '/') {
879 /*
880 * Path ending in '/' was mapped to JSP servlet based on wildcard match (e.g., as specified in
881 * url-pattern of a jsp-property-group). Force the context's welcome files, which are interpreted as
882 * JSP files (since they match the url-pattern), to be considered. See Bugzilla 27664.
883 */
884 mappingData.wrapper = null;
885 checkJspWelcomeFiles = true;
886 } else {
887 // See Bugzilla 27704
888 mappingData.wrapperPath.setChars(buf, path.getStart(), path.getLength());
889 mappingData.pathInfo.recycle();
890 }
891 }
892 }
893
894 if (mappingData.wrapper == null && noServletPath &&
895 contextVersion.object.getMapperContextRootRedirectEnabled()) {
896 // The path is empty, redirect to "/"
897 path.append('/');
898 pathEnd = path.getEnd();
899 mappingData.redirectPath.setChars(path.getBuffer(), pathStart, pathEnd - pathStart);
900 path.setEnd(pathEnd - 1);
901 return;
902 }
903
904 // Rule 3 -- Extension Match
905 MappedWrapper[] extensionWrappers = contextVersion.extensionWrappers;
906 if (mappingData.wrapper == null && !checkJspWelcomeFiles) {
907 internalMapExtensionWrapper(extensionWrappers, path, mappingData, true);
908 }
909
910 // Rule 4 -- Welcome resources processing for servlets

Callers 2

mapMethod · 0.95
internalMapMethod · 0.95

Calls 15

isFileMethod · 0.95
isDirectoryMethod · 0.95
lengthMethod · 0.80
setStartMethod · 0.80
setEndMethod · 0.80
getBufferMethod · 0.65
getLengthMethod · 0.65
recycleMethod · 0.65

Tested by

no test coverage detected