svn commit: r918731 - /ofbiz/trunk/framework/entity/src/org/ofbiz/entity/datasource/GenericDAO.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r918731 - /ofbiz/trunk/framework/entity/src/org/ofbiz/entity/datasource/GenericDAO.java

doogie-3
Author: doogie
Date: Wed Mar  3 22:13:52 2010
New Revision: 918731

URL: http://svn.apache.org/viewvc?rev=918731&view=rev
Log:
Make use of FastMap's putIfAbsent, and remove an instance of
double-checked-locking.

Modified:
    ofbiz/trunk/framework/entity/src/org/ofbiz/entity/datasource/GenericDAO.java

Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/datasource/GenericDAO.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/datasource/GenericDAO.java?rev=918731&r1=918730&r2=918731&view=diff
==============================================================================
--- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/datasource/GenericDAO.java (original)
+++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/datasource/GenericDAO.java Wed Mar  3 22:13:52 2010
@@ -70,7 +70,7 @@
 
     public static final String module = GenericDAO.class.getName();
 
-    private static final Map<String, GenericDAO> genericDAOs = FastMap.newInstance();
+    private static final FastMap<String, GenericDAO> genericDAOs = FastMap.newInstance();
     private final String helperName;
     private final ModelFieldTypeReader modelFieldTypeReader;
     private final DatasourceInfo datasourceInfo;
@@ -78,14 +78,9 @@
     public static GenericDAO getGenericDAO(String helperName) {
         GenericDAO newGenericDAO = genericDAOs.get(helperName);
 
-        if (newGenericDAO == null) { // don't want to block here
-            synchronized (GenericDAO.class) {
-                newGenericDAO = genericDAOs.get(helperName);
-                if (newGenericDAO == null) {
-                    newGenericDAO = new GenericDAO(helperName);
-                    genericDAOs.put(helperName, newGenericDAO);
-                }
-            }
+        if (newGenericDAO == null) {
+            genericDAOs.putIfAbsent(helperName, new GenericDAO(helperName));
+            newGenericDAO = genericDAOs.get(helperName);
         }
         return newGenericDAO;
     }