Author: kkolinko Date: Sat Jan 16 05:17:08 2016 New Revision: 1724913 URL: http://svn.apache.org/viewvc?rev=1724913&view=rev Log: For https://bz.apache.org/bugzilla/show_bug.cgi?id=57154 Review of r1681953 In EmptyDirContext.java: - Remove @author tag from new code. The author is credited in the changelog. - Use ImmutableNameNotFoundException as the cached exception instance. Caching a plain NameNotFoundException is wrong, as it has a stacktrace. Such pattern is a known source of PermGen memory leak, as staktrace keeps classes and their classloaders in memory (see https://bz.apache.org/bugzilla/show_bug.cgi?id=50460 )
In StandardContext.java: - Remove redundant docBase != null check from the second branch of an elif tree. The null case is handled by the first branch. Modified: tomcat/tc7.0.x/trunk/java/org/apache/catalina/core/StandardContext.java tomcat/tc7.0.x/trunk/java/org/apache/naming/resources/EmptyDirContext.java Modified: tomcat/tc7.0.x/trunk/java/org/apache/catalina/core/StandardContext.java URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/catalina/core/StandardContext.java?rev=1724913&r1=1724912&r2=1724913&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/java/org/apache/catalina/core/StandardContext.java (original) +++ tomcat/tc7.0.x/trunk/java/org/apache/catalina/core/StandardContext.java Sat Jan 16 05:17:08 2016 @@ -5377,13 +5377,15 @@ public class StandardContext extends Con if (log.isDebugEnabled()) log.debug("Configuring default Resources"); try { - if (getDocBase() == null) + String docBase = getDocBase(); + if (docBase == null) { setResources(new EmptyDirContext()); - else if ((getDocBase() != null) && (getDocBase().endsWith(".war")) && - (!(new File(getBasePath())).isDirectory())) + } else if (docBase.endsWith(".war") + && !(new File(getBasePath())).isDirectory()) { setResources(new WARDirContext()); - else + } else { setResources(new FileDirContext()); + } } catch (IllegalArgumentException e) { log.error(sm.getString("standardContext.resourcesInit"), e); ok = false; Modified: tomcat/tc7.0.x/trunk/java/org/apache/naming/resources/EmptyDirContext.java URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/naming/resources/EmptyDirContext.java?rev=1724913&r1=1724912&r2=1724913&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/java/org/apache/naming/resources/EmptyDirContext.java (original) +++ tomcat/tc7.0.x/trunk/java/org/apache/naming/resources/EmptyDirContext.java Sat Jan 16 05:17:08 2016 @@ -42,8 +42,6 @@ import javax.naming.directory.SearchResu * embedded mode when the web application is configured entirely * programmatically and does not use any static resources from the file system. * EmptyDirContext is implemented as a read only context. - * - * @author Huxing Zhang (huxing....@alibaba-inc.com) */ public class EmptyDirContext implements DirContext { @@ -52,7 +50,7 @@ public class EmptyDirContext implements */ private static final Attributes emptyAttributes = new BasicAttributes(); - private static final NameNotFoundException nameNotFoundException = new NameNotFoundException(); + private static final NameNotFoundException nameNotFoundException = new ImmutableNameNotFoundException(); private static final Name emptyName = new CompositeName(); --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org