cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ja...@apache.org
Subject svn commit: r959219 - /cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/core/container/spring/avalon/PoolableProxyHandler.java
Date Wed, 30 Jun 2010 07:40:41 GMT
Author: jasha
Date: Wed Jun 30 07:40:41 2010
New Revision: 959219

URL: http://svn.apache.org/viewvc?rev=959219&view=rev
Log:
COCOON-2259 Fix for Memory leak in PoolableProxyHandler. Patch by Alexander Daniel.

Modified:
    cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/core/container/spring/avalon/PoolableProxyHandler.java

Modified: cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/core/container/spring/avalon/PoolableProxyHandler.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/core/container/spring/avalon/PoolableProxyHandler.java?rev=959219&r1=959218&r2=959219&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/core/container/spring/avalon/PoolableProxyHandler.java
(original)
+++ cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/core/container/spring/avalon/PoolableProxyHandler.java
Wed Jun 30 07:40:41 2010
@@ -20,6 +20,8 @@ import java.lang.reflect.InvocationHandl
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 import org.springframework.web.context.request.RequestAttributes;
 import org.springframework.web.context.request.RequestContextHolder;
 
@@ -31,13 +33,16 @@ import org.springframework.web.context.r
  */
 public class PoolableProxyHandler implements InvocationHandler, Runnable {
 
+    /** Logger (we use the same logging mechanism as Spring!) */
+	private final Log log = LogFactory.getLog(getClass());
+
     private final ThreadLocal componentHolder = new ThreadLocal();
     private final PoolableFactoryBean handler;
     private final String attributeName;
 
     public PoolableProxyHandler(PoolableFactoryBean handler) {
         this.handler = handler;
-        this.attributeName = PoolableProxyHandler.class.getName() + '/' + this.handler.hashCode();
+        this.attributeName = PoolableProxyHandler.class.getName() + '/' + this.hashCode();
// see https://issues.apache.org/jira/browse/COCOON-2259
     }
 
     /**
@@ -66,6 +71,9 @@ public class PoolableProxyHandler implem
         if ( this.componentHolder.get() == null ) {
             this.componentHolder.set(this.handler.getFromPool());
             RequestContextHolder.currentRequestAttributes().registerDestructionCallback(this.attributeName,
this, RequestAttributes.SCOPE_REQUEST);
+            if (log.isDebugEnabled()) {
+            	log.debug("getFromPool attributeName=" + attributeName + " class=" + componentHolder.get().getClass());
+            }
         }
         try {
             return method.invoke(this.componentHolder.get(), args);
@@ -81,6 +89,13 @@ public class PoolableProxyHandler implem
         final Object o = this.componentHolder.get();
         if ( o != null ) {
             this.handler.putIntoPool(o);
+            if (log.isDebugEnabled()) {
+            	log.debug("putIntoPool attributeName=" + attributeName + " class=" + componentHolder.get().getClass());
+            }
+        } else {
+        	if (log.isDebugEnabled()) {
+        		log.debug("no object to put into pool  attributeName=" + attributeName);
+        	}
         }
         this.componentHolder.set(null);
     }



Mime
View raw message