MCPcopy Create free account
hub / github.com/apache/tomcat / setPath

Method setPath

java/org/apache/catalina/core/StandardContext.java:2093–2116  ·  view source on GitHub ↗
(String path)

Source from the content-addressed store, hash-verified

2091
2092
2093 @Override
2094 public void setPath(String path) {
2095 boolean invalid = false;
2096 if (path == null || path.equals("/")) {
2097 invalid = true;
2098 this.path = "";
2099 } else if (path.isEmpty() || path.startsWith("/")) {
2100 this.path = path;
2101 } else {
2102 invalid = true;
2103 this.path = "/" + path;
2104 }
2105 if (this.path.endsWith("/")) {
2106 invalid = true;
2107 this.path = this.path.substring(0, this.path.length() - 1);
2108 }
2109 if (invalid) {
2110 log.warn(sm.getString("standardContext.pathInvalid", path, this.path));
2111 }
2112 encodedPath = URLEncoder.DEFAULT.encode(this.path, StandardCharsets.UTF_8);
2113 if (getName() == null) {
2114 setName(this.path);
2115 }
2116 }
2117
2118
2119 @Override

Callers 4

testSetPathMethod · 0.95
testBug57190Method · 0.95
createStandardContextMethod · 0.95

Calls 10

endsWithMethod · 0.80
lengthMethod · 0.80
equalsMethod · 0.65
warnMethod · 0.65
getStringMethod · 0.65
encodeMethod · 0.65
getNameMethod · 0.65
setNameMethod · 0.65
isEmptyMethod · 0.45
startsWithMethod · 0.45

Tested by 3

testSetPathMethod · 0.76
testBug57190Method · 0.76