doLookup should return null if the resource cannot be found and should not throw an exception
Fixes a potential infinite loop in VirtualDirContext
git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@943447
13f79535-47bb-0310-9956-
ffa450edef68
protected abstract Attributes doGetAttributes(String name, String[] attrIds)
throws NamingException;
- protected abstract Object doLookup(String name) throws NamingException;
+ protected abstract Object doLookup(String name);
protected abstract NamingEnumeration<Binding> doListBindings(String name)
throws NamingException;
*
* @param name the name of the object to look up
* @return the object bound to name
- * @exception NamingException if a naming exception is encountered
*/
@Override
- protected Object doLookup(String name)
- throws NamingException {
+ protected Object doLookup(String name) {
Object result = null;
File file = file(name);
resources.invalidAliasNotAllowed=The alias location ''{0}'' is not allowed
resources.invalidAliasNotExist=The alias location ''{0}'' does not exist
resources.invalidAliasFile=The alias location ''{0}'' points to a file that is not a WAR file
+resources.invalidName=The name [{0}] is not valid
standardResources.alreadyStarted=Resources has already been started
standardResources.directory=File base {0} is not a directory
standardResources.exists=File base {0} does not exist
}
@Override
- protected Object doLookup(String name) throws NamingException {
+ protected Object doLookup(String name) {
// handle "virtual" tlds
if (name.startsWith("/WEB-INF/") && name.endsWith(".tld")) {
}
}
- return super.lookup(name);
+ return super.doLookup(name);
}
/**
import javax.naming.Binding;
import javax.naming.CompositeName;
+import javax.naming.InvalidNameException;
import javax.naming.Name;
import javax.naming.NameClassPair;
import javax.naming.NamingEnumeration;
*
* @param strName the name of the object to look up
* @return the object bound to name
- * @exception NamingException if a naming exception is encountered
*/
@Override
- protected Object doLookup(String strName)
- throws NamingException {
+ protected Object doLookup(String strName) {
- Name name = new CompositeName(strName);
+ Name name;
+ try {
+ name = new CompositeName(strName);
+ } catch (InvalidNameException e) {
+ log.info(sm.getString("resources.invalidName", strName), e);
+ return null;
+ }
if (name.isEmpty())
return this;