svn commit: r1491165 - /ofbiz/trunk/framework/entity/src/org/ofbiz/entity/connection/DBCPConnectionFactory.java

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

svn commit: r1491165 - /ofbiz/trunk/framework/entity/src/org/ofbiz/entity/connection/DBCPConnectionFactory.java

adrianc
Author: adrianc
Date: Sun Jun  9 09:24:49 2013
New Revision: 1491165

URL: http://svn.apache.org/r1491165
Log:
Fixed a thread deadlock issue that seems to be specific to loading the MS SQL JDBC driver.

https://issues.apache.org/jira/browse/OFBIZ-5216

Modified:
    ofbiz/trunk/framework/entity/src/org/ofbiz/entity/connection/DBCPConnectionFactory.java

Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/connection/DBCPConnectionFactory.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/connection/DBCPConnectionFactory.java?rev=1491165&r1=1491164&r2=1491165&view=diff
==============================================================================
--- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/connection/DBCPConnectionFactory.java (original)
+++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/connection/DBCPConnectionFactory.java Sun Jun  9 09:24:49 2013
@@ -81,11 +81,14 @@ public class DBCPConnectionFactory imple
         maxIdle = maxIdle > minSize ? maxIdle : minSize;
         // load the driver
         Driver jdbcDriver;
-        try {
-            jdbcDriver = (Driver) Class.forName(driverName, true, Thread.currentThread().getContextClassLoader()).newInstance();
-        } catch (Exception e) {
-            Debug.logError(e, module);
-            throw new GenericEntityException(e.getMessage(), e);
+        synchronized (DBCPConnectionFactory.class) {
+            // Sync needed for MS SQL JDBC driver. See OFBIZ-5216.
+            try {
+                jdbcDriver = (Driver) Class.forName(driverName, true, Thread.currentThread().getContextClassLoader()).newInstance();
+            } catch (Exception e) {
+                Debug.logError(e, module);
+                throw new GenericEntityException(e.getMessage(), e);
+            }
         }
 
         // connection factory properties