incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r898374 - /sling/trunk/bundles/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/runtime/JspFactoryImpl.java
Date Tue, 12 Jan 2010 15:36:19 GMT
Author: cziegeler
Date: Tue Jan 12 15:36:18 2010
New Revision: 898374

URL: http://svn.apache.org/viewvc?rev=898374&view=rev
Log:
SLING-1284 : MemoryLeak: ThreadLocal variable is never cleared

Modified:
    sling/trunk/bundles/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/runtime/JspFactoryImpl.java

Modified: sling/trunk/bundles/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/runtime/JspFactoryImpl.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/runtime/JspFactoryImpl.java?rev=898374&r1=898373&r2=898374&view=diff
==============================================================================
--- sling/trunk/bundles/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/runtime/JspFactoryImpl.java
(original)
+++ sling/trunk/bundles/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/runtime/JspFactoryImpl.java
Tue Jan 12 15:36:18 2010
@@ -43,13 +43,6 @@
     private Log log = LogFactory.getLog(JspFactoryImpl.class);
 
     private static final String SPEC_VERSION = "2.1";
-    private static final boolean USE_POOL = false;
-        //Boolean.valueOf(System.getProperty("org.apache.sling.scripting.jsp.jasper.runtime.JspFactoryImpl.USE_POOL",
"false")).booleanValue();
-
-        private static final int POOL_SIZE =
-        Integer.valueOf(System.getProperty("org.apache.sling.scripting.jsp.jasper.runtime.JspFactoryImpl.POOL_SIZE",
"8")).intValue();
-
-    private ThreadLocal<PageContextPool> localPool = new ThreadLocal<PageContextPool>();
 
     public PageContext getPageContext(Servlet servlet, ServletRequest request,
             ServletResponse response, String errorPageURL, boolean needsSession,
@@ -91,20 +84,7 @@
             ServletResponse response, String errorPageURL, boolean needsSession,
             int bufferSize, boolean autoflush) {
         try {
-            PageContext pc;
-            if (USE_POOL) {
-                PageContextPool pool = localPool.get();
-                if (pool == null) {
-                    pool = new PageContextPool();
-                    localPool.set(pool);
-                }
-                pc = pool.get();
-                if (pc == null) {
-                    pc = new PageContextImpl();
-                }
-            } else {
-                pc = new PageContextImpl();
-            }
+            PageContext pc = new PageContextImpl();
             pc.initialize(servlet, request, response, errorPageURL,
                     needsSession, bufferSize, autoflush);
             return pc;
@@ -117,9 +97,6 @@
 
     private void internalReleasePageContext(PageContext pc) {
         pc.release();
-        if (USE_POOL && (pc instanceof PageContextImpl)) {
-            localPool.get().put(pc);
-        }
     }
 
     private class PrivilegedGetPageContext implements PrivilegedAction {
@@ -169,34 +146,6 @@
         }
     }
 
-    protected final class PageContextPool  {
-
-        private PageContext[] pool;
-
-        private int current = -1;
-
-        public PageContextPool() {
-            this.pool = new PageContext[POOL_SIZE];
-        }
-
-        public void put(PageContext o) {
-            if (current < (POOL_SIZE - 1)) {
-                current++;
-                pool[current] = o;
-            }
-        }
-
-        public PageContext get() {
-            PageContext item = null;
-            if (current >= 0) {
-                item = pool[current];
-                current--;
-            }
-            return item;
-        }
-
-    }
-
     public JspApplicationContext getJspApplicationContext(ServletContext context) {
         return JspApplicationContextImpl.getInstance(context);
     }



Mime
View raw message