commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1506855 - /commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/PooledObjectImpl.java
Date Thu, 25 Jul 2013 09:18:06 GMT
Author: markt
Date: Thu Jul 25 09:18:06 2013
New Revision: 1506855

URL: http://svn.apache.org/r1506855
Log:
Trace where objects were borrowed rather than where they were created for abandoned object
logging.

Modified:
    commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/PooledObjectImpl.java

Modified: commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/PooledObjectImpl.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/PooledObjectImpl.java?rev=1506855&r1=1506854&r2=1506855&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/PooledObjectImpl.java
(original)
+++ commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/PooledObjectImpl.java
Thu Jul 25 09:18:06 2013
@@ -46,7 +46,7 @@ public class PooledObjectImpl<T> impleme
     private volatile long lastBorrowTime = createTime;
     private volatile long lastReturnTime = createTime;
     private AtomicBoolean abandonedLogConfigured = new AtomicBoolean(false);
-    private Exception createdBy = null;
+    private Exception borrowedBy = null;
     private PrintWriter logWriter = null;
 
     public PooledObjectImpl(T object) {
@@ -216,6 +216,9 @@ public class PooledObjectImpl<T> impleme
         if (state == PooledObjectState.IDLE) {
             state = PooledObjectState.ALLOCATED;
             lastBorrowTime = System.currentTimeMillis();
+            if (abandonedLogConfigured.get()) {
+                borrowedBy = new AbandonedObjectException();
+            }
             return true;
         } else if (state == PooledObjectState.EVICTION) {
             // TODO Allocate anyway and ignore eviction test
@@ -239,6 +242,9 @@ public class PooledObjectImpl<T> impleme
                 state == PooledObjectState.RETURNING) {
             state = PooledObjectState.IDLE;
             lastReturnTime = System.currentTimeMillis();
+            if (abandonedLogConfigured.get()) {
+                borrowedBy = null;
+            }
             return true;
         }
 
@@ -254,14 +260,14 @@ public class PooledObjectImpl<T> impleme
     }
 
     /**
-     * Prints the stack trace of the code that created this pooled object to
+     * Prints the stack trace of the code that borrowed this pooled object to
      * the configured log writer.  Does nothing of no PrintWriter was supplied
      * to the constructor.
      */
     @Override
     public void printStackTrace() {
-        if (createdBy != null && logWriter != null) {
-            createdBy.printStackTrace(logWriter);
+        if (borrowedBy != null && logWriter != null) {
+            borrowedBy.printStackTrace(logWriter);
         }
     }
 
@@ -298,7 +304,6 @@ public class PooledObjectImpl<T> impleme
         if (abandonedLogConfigured.compareAndSet(false, true)) {
             if (logWriter != null) {
                 this.logWriter = logWriter;
-                createdBy = new AbandonedObjectException();
             }
         }
     }



Mime
View raw message