commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1333149 - /commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/GenericKeyedObjectPool.java
Date Wed, 02 May 2012 18:37:56 GMT
Author: markt
Date: Wed May  2 18:37:56 2012
New Revision: 1333149

URL: http://svn.apache.org/viewvc?rev=1333149&view=rev
Log:
Used for read and write

Modified:
    commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/GenericKeyedObjectPool.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=1333149&r1=1333148&r2=1333149&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
Wed May  2 18:37:56 2012
@@ -1014,16 +1014,16 @@ public class GenericKeyedObjectPool<K,T>
      * register() and deregister() must always be used as a pair.
      */
     private ObjectDeque<T> register(K k) {
-        Lock readLock = keyLock.readLock();
+        Lock lock = keyLock.readLock();
         ObjectDeque<T> objectDeque = null;
         try {
-            readLock.lock();
+            lock.lock();
             objectDeque = poolMap.get(k);
             if (objectDeque == null) {
                 // Upgrade to write lock
-                readLock.unlock();
-                readLock = keyLock.writeLock();
-                readLock.lock();
+                lock.unlock();
+                lock = keyLock.writeLock();
+                lock.lock();
                 objectDeque = poolMap.get(k);
                 if (objectDeque == null) {
                     objectDeque = new ObjectDeque<T>();
@@ -1040,7 +1040,7 @@ public class GenericKeyedObjectPool<K,T>
                 objectDeque.getNumInterested().incrementAndGet();
             }
         } finally {
-            readLock.unlock();
+            lock.unlock();
         }
         return objectDeque;
     }



Mime
View raw message