commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1329735 - in /commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl: GenericKeyedObjectPool.java GenericObjectPool.java
Date Tue, 24 Apr 2012 14:07:59 GMT
Author: markt
Date: Tue Apr 24 14:07:58 2012
New Revision: 1329735

URL: http://svn.apache.org/viewvc?rev=1329735&view=rev
Log:
Align GOP and GKOP so it is easier to check they are consistent (not complete)

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

Modified: commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/GenericKeyedObjectPool.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/GenericKeyedObjectPool.java?rev=1329735&r1=1329734&r2=1329735&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/GenericKeyedObjectPool.java
(original)
+++ commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/GenericKeyedObjectPool.java
Tue Apr 24 14:07:58 2012
@@ -836,7 +836,6 @@ public class GenericKeyedObjectPool<K,T>
      * @throws NoSuchElementException if a keyed object instance cannot be returned.
      */
     public T borrowObject(K key, long borrowMaxWait) throws Exception {
-
         assertOpen();
 
         PooledObject<T> p = null;
@@ -977,15 +976,14 @@ public class GenericKeyedObjectPool<K,T>
      * </p>
      * 
      * @param key pool key
-     * @param t instance to return to the keyed pool
-     * @throws Exception
+     * @param obj instance to return to the keyed pool
      */
     @Override
-    public void returnObject(K key, T t) throws Exception {
+    public void returnObject(K key, T obj) {
 
         ObjectDeque<T> objectDeque = poolMap.get(key);
 
-        PooledObject<T> p = objectDeque.getAllObjects().get(t);
+        PooledObject<T> p = objectDeque.getAllObjects().get(obj);
 
         if (p == null) {
             throw new IllegalStateException(
@@ -995,7 +993,7 @@ public class GenericKeyedObjectPool<K,T>
         long activeTime = p.getActiveTimeMillis();
 
         if (getTestOnReturn()) {
-            if (!factory.validateObject(key, t)) {
+            if (!factory.validateObject(key, obj)) {
                 try {
                     destroy(key, p, true);
                 } catch (Exception e) {
@@ -1007,7 +1005,7 @@ public class GenericKeyedObjectPool<K,T>
         }
 
         try {
-            factory.passivateObject(key, t);
+            factory.passivateObject(key, obj);
         } catch (Exception e1) {
             swallowException(e1);
             try {
@@ -1049,6 +1047,13 @@ public class GenericKeyedObjectPool<K,T>
         updateStatsReturn(activeTime);
     }
 
+    private void updateStatsReturn(long activeTime) {
+        returnedCount.incrementAndGet();
+        synchronized (activeTimes) {
+            activeTimes.add(Long.valueOf(activeTime));
+            activeTimes.poll();
+        }
+    }
      
     private void swallowException(Exception e) {
         String msg = getStackTrace(e);
@@ -1076,14 +1081,6 @@ public class GenericKeyedObjectPool<K,T>
         return w.toString();
     }
          
-    private void updateStatsReturn(long activeTime) {
-        returnedCount.incrementAndGet();
-        synchronized (activeTimes) {
-            activeTimes.add(Long.valueOf(activeTime));
-            activeTimes.poll();
-        }
-    }
-
 
     /**
      * {@inheritDoc}

Modified: commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/GenericObjectPool.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/GenericObjectPool.java?rev=1329735&r1=1329734&r2=1329735&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/GenericObjectPool.java
(original)
+++ commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/GenericObjectPool.java
Tue Apr 24 14:07:58 2012
@@ -1111,6 +1111,7 @@ public class GenericObjectPool<T> extend
             startEvictor(-1L);
 
             super.close();
+            // This clear removes any idle objects
             clear();
             if (oname != null) {
                 ManagementFactory.getPlatformMBeanServer().unregisterMBean(



Mime
View raw message