https://bz.apache.org/bugzilla/show_bug.cgi?id=69142
Bug ID: 69142
Summary: FileResourceSet allocates unnecessary Strings
Product: Tomcat 9
Version: 9.0.x
Hardware: All
OS: All
Status: NEW
Severity: normal
Priority: P2
Component: Catalina
Assignee: [email protected]
Reporter: [email protected]
Target Milestone: -----
The method
'org.apache.catalina.webresources.FileResourceSet.getResource(String)' has
logic that in the common case (for us, anyway) appends a '/' to a String, then
immediately strips it back out. The repeated concatenation means repeated
object allocation, and as this is a hot path, it impacts our startup time and
our request-handling time (we have unfortunate classpath scans during each
request).
In version 9.x, the append occurs at FileResourceSet.java#L83 and the character
is stripped at FileResourceSet.java#L87. Rewriting that code to avoid the
duplication would be isolated, safe, and helpful.
A clunky example of that rewrite is:
if (path.charAt(path.length() - 1) != '/')
if (webAppMount.startsWith(path)) {
String name = path;
name = name.substring(name.lastIndexOf('/') + 1);
if (name.length() > 0) {
return new VirtualResource(root, path, name);
}
} else {
path = path + '/';
}
else if (webAppMount.startsWith(path)) {
String name = path.substring(0, path.length() - 1);
name = name.substring(name.lastIndexOf('/') + 1);
if (name.length() > 0) {
return new VirtualResource(root, path, name);
}
}
return new EmptyResource(root, path);
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]