This is an automated email from the ASF dual-hosted git repository.
remm pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/main by this push:
new 7bc405e31f Optimize directory listing
7bc405e31f is described below
commit 7bc405e31f864795448a0f2024206e76b078d916
Author: remm <[email protected]>
AuthorDate: Fri Apr 4 10:45:11 2025 +0200
Optimize directory listing
69643: Optimize directory listing for large amount of files.
Patch submitted by Loic de l'Eprevier.
---
java/org/apache/catalina/webresources/DirResourceSet.java | 5 ++++-
webapps/docs/changelog.xml | 4 ++++
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/java/org/apache/catalina/webresources/DirResourceSet.java
b/java/org/apache/catalina/webresources/DirResourceSet.java
index 04fe6ca2a9..04bc2d3e4e 100644
--- a/java/org/apache/catalina/webresources/DirResourceSet.java
+++ b/java/org/apache/catalina/webresources/DirResourceSet.java
@@ -169,6 +169,7 @@ public class DirResourceSet extends AbstractFileResourceSet
implements WebResour
if (f != null) {
File[] list = f.listFiles();
if (list != null) {
+ String fCanPath = null;
for (File entry : list) {
// f has already been validated so the following checks
// can be much simpler than those in file()
@@ -186,7 +187,9 @@ public class DirResourceSet extends AbstractFileResourceSet
implements WebResour
// that what is left does not contain a
symlink.
absPath =
entry.getAbsolutePath().substring(f.getAbsolutePath().length());
String entryCanPath = entry.getCanonicalPath();
- String fCanPath = f.getCanonicalPath();
+ if (fCanPath == null) {
+ fCanPath = f.getCanonicalPath();
+ }
if (entryCanPath.length() >=
fCanPath.length()) {
canPath =
entryCanPath.substring(fCanPath.length());
if (absPath.equals(canPath)) {
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index a046154488..a91d666576 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -161,6 +161,10 @@
Process possible path parameters rewrite production in the rewrite
valve. (remm)
</fix>
+ <fix>
+ <bug>69643</bug>: Optimize directory listing for large amount of files.
+ Patch submitted by Loic de l'Eprevier. (remm)
+ </fix>
</changelog>
</subsection>
<subsection name="Coyote">
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]