You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by si...@apache.org on 2012/02/05 01:03:32 UTC

svn commit: r1240648 - /commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/PropertyDescriptorsRegistry.java

Author: simonetripodi
Date: Sun Feb  5 00:03:32 2012
New Revision: 1240648

URL: http://svn.apache.org/viewvc?rev=1240648&view=rev
Log:
one locking level is more than enough

Modified:
    commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/PropertyDescriptorsRegistry.java

Modified: commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/PropertyDescriptorsRegistry.java
URL: http://svn.apache.org/viewvc/commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/PropertyDescriptorsRegistry.java?rev=1240648&r1=1240647&r2=1240648&view=diff
==============================================================================
--- commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/PropertyDescriptorsRegistry.java (original)
+++ commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/PropertyDescriptorsRegistry.java Sun Feb  5 00:03:32 2012
@@ -31,8 +31,7 @@ import java.util.HashMap;
 import java.util.Map;
 import java.util.WeakHashMap;
 import java.util.concurrent.locks.Lock;
-import java.util.concurrent.locks.ReadWriteLock;
-import java.util.concurrent.locks.ReentrantReadWriteLock;
+import java.util.concurrent.locks.ReentrantLock;
 
 /**
  *
@@ -49,8 +48,6 @@ final class PropertyDescriptorsRegistry
 
     private final AccessibleObjectsRegistry<Method> methodsRegistry = AccessibleObjectsRegistry.getMethodsRegistry();
 
-    private final ReadWriteLock lock = new ReentrantReadWriteLock();
-
     private final Map<Class<?>, WeakReference<Map<String, PropertyDescriptor>>> cache =
                     new WeakHashMap<Class<?>, WeakReference<Map<String, PropertyDescriptor>>>();
 
@@ -65,8 +62,8 @@ final class PropertyDescriptorsRegistry
     public Map<String, PropertyDescriptor> getPropertiesIndex( Class<?> beanType )
         throws IntrospectionException
     {
-        Lock readLock = lock.readLock();
-        readLock.lock();
+        final Lock lock = new ReentrantLock();
+        lock.lock();
         try
         {
             Reference<Map<String, PropertyDescriptor>> methodReference = cache.get( beanType );
@@ -74,16 +71,7 @@ final class PropertyDescriptorsRegistry
             {
                 return methodReference.get();
             }
-        }
-        finally
-        {
-            readLock.unlock();
-        }
 
-        Lock writeLock = lock.writeLock();
-        writeLock.lock();
-        try
-        {
             final Map<String, PropertyDescriptor> propertiesIndex = new HashMap<String, PropertyDescriptor>();
             BeanInfo beanInfo = getBeanInfo( beanType );
 
@@ -99,7 +87,7 @@ final class PropertyDescriptorsRegistry
         }
         finally
         {
-            writeLock.unlock();
+            lock.unlock();
         }
     }