You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by kk...@apache.org on 2014/09/13 00:42:07 UTC

svn commit: r1624665 - in /tomcat/tc7.0.x/trunk: ./ java/org/apache/catalina/startup/ContextConfig.java

Author: kkolinko
Date: Fri Sep 12 22:42:07 2014
New Revision: 1624665

URL: http://svn.apache.org/r1624665
Log:
Memory efficiency: Use a shared emptySet() as the value for JavaClassCacheEntry.sciSet when there are no SCIs for a class.

It is merge of r1624655 from tomcat/trunk.

Modified:
    tomcat/tc7.0.x/trunk/   (props changed)
    tomcat/tc7.0.x/trunk/java/org/apache/catalina/startup/ContextConfig.java

Propchange: tomcat/tc7.0.x/trunk/
------------------------------------------------------------------------------
  Merged /tomcat/trunk:r1624655

Modified: tomcat/tc7.0.x/trunk/java/org/apache/catalina/startup/ContextConfig.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/catalina/startup/ContextConfig.java?rev=1624665&r1=1624664&r2=1624665&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/org/apache/catalina/startup/ContextConfig.java (original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/catalina/startup/ContextConfig.java Fri Sep 12 22:42:07 2014
@@ -194,6 +194,13 @@ public class ContextConfig implements Li
         new ConcurrentHashMap<Host,DefaultWebXmlCacheEntry>();
 
 
+    /**
+     * Set used as the value for {@code JavaClassCacheEntry.sciSet} when there
+     * are no SCIs associated with a class.
+     */
+    private static final Set<ServletContainerInitializer> EMPTY_SCI_SET = Collections.emptySet();
+
+
     // ----------------------------------------------------- Instance Variables
     /**
      * Custom mappings of login methods to authenticators
@@ -2121,7 +2128,7 @@ public class ContextConfig implements Li
                             classHierarchyToString(className, entry)));
                 }
             }
-            if (entry.getSciSet().size() > 0) {
+            if (!entry.getSciSet().isEmpty()) {
                 // Need to try and load the class
                 clazz = Introspection.loadClass(context, className);
                 if (clazz == null) {
@@ -2129,8 +2136,7 @@ public class ContextConfig implements Li
                     return;
                 }
 
-                for (ServletContainerInitializer sci :
-                        entry.getSciSet()) {
+                for (ServletContainerInitializer sci : entry.getSciSet()) {
                     Set<Class<?>> classes = initializerClassMap.get(sci);
                     if (classes == null) {
                         classes = new HashSet<Class<?>>();
@@ -2249,7 +2255,7 @@ public class ContextConfig implements Li
 
         // Avoid an infinite loop with java.lang.Object
         if (cacheEntry.equals(superClassCacheEntry)) {
-            cacheEntry.setSciSet(new HashSet<ServletContainerInitializer>());
+            cacheEntry.setSciSet(EMPTY_SCI_SET);
             return;
         }
 
@@ -2278,7 +2284,7 @@ public class ContextConfig implements Li
             result.addAll(getSCIsForClass(interfaceName));
         }
 
-        cacheEntry.setSciSet(result);
+        cacheEntry.setSciSet(result.isEmpty() ? EMPTY_SCI_SET : result);
     }
 
     private Set<ServletContainerInitializer> getSCIsForClass(String className) {
@@ -2291,7 +2297,7 @@ public class ContextConfig implements Li
                 }
             }
         }
-        return Collections.emptySet();
+        return EMPTY_SCI_SET;
     }
 
     private static final String getClassName(String internalForm) {



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org