From: markt Date: Fri, 3 Oct 2008 12:09:16 +0000 (+0000) Subject: Better fix for https://issues.apache.org/bugzilla/show_bug.cgi?id=45403 X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=1e9580cfde385aa46bc9f521afb8ca7471ea73e2;p=tomcat7.0 Better fix for https://issues.apache.org/bugzilla/show_bug.cgi?id=45403 With this patch, the allowLinking flag applies to all web application resources. It is very slightly slower. On my machine with allowLinking=false, the change to line 899 increases the time from ~7 microseconds to create the file to ~70 microseconds to create and validate the file. As far as I can tell, this change is only going to affect context start times. If directory listings are enabled in the default servlet, they will also be slightly slower but they were horribly slow to start with. git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@701358 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/java/org/apache/naming/resources/FileDirContext.java b/java/org/apache/naming/resources/FileDirContext.java index 58e54e46d..bd9546d4b 100644 --- a/java/org/apache/naming/resources/FileDirContext.java +++ b/java/org/apache/naming/resources/FileDirContext.java @@ -819,6 +819,15 @@ public class FileDirContext extends BaseDirContext { protected File file(String name) { File file = new File(base, name); + return validate(file); + + } + + + /* + * Check that the file is valid for this context + */ + private File validate(File file) { if (file.exists() && file.canRead()) { if (allowLinking) @@ -896,7 +905,9 @@ public class FileDirContext extends BaseDirContext { for (int i = 0; i < names.length; i++) { - File currentFile = new File(file, names[i]); + File currentFile = validate(new File(file, names[i])); + if (currentFile == null) continue; + Object object = null; if (currentFile.isDirectory()) { FileDirContext tempContext = new FileDirContext(env);