details:   https://code.openbravo.com/erp/devel/pi/rev/be9628eb6222
changeset: 32294:be9628eb6222
user:      Asier Lostalé <asier.lostale <at> openbravo.com>
date:      Mon Jun 12 13:52:53 2017 +0200
summary:   fixed bug 36228: SimpleCallout borrows 2 connections in same thread

  When a SimpleCallout is used as ConnectionProvider (using this to get
  connection), it borrows a second connection in the thread in addition to the
  Dal's one.

  Fixed by obtaining ConnectionProvider instance from DAL's one, so that
  it reuses the same connection already borrowed in current thread.

  Note this is safe as callout instances are not shared among different threads.

diffstat:

 src/org/openbravo/erpCommon/ad_callouts/DelegateConnectionProvider.java |  13 
++-------
 1 files changed, 3 insertions(+), 10 deletions(-)

diffs (42 lines):

diff -r e4a51675b08b -r be9628eb6222 
src/org/openbravo/erpCommon/ad_callouts/DelegateConnectionProvider.java
--- a/src/org/openbravo/erpCommon/ad_callouts/DelegateConnectionProvider.java   
Mon Jun 12 12:34:23 2017 +0200
+++ b/src/org/openbravo/erpCommon/ad_callouts/DelegateConnectionProvider.java   
Mon Jun 12 13:52:53 2017 +0200
@@ -24,13 +24,11 @@
 import java.sql.SQLException;
 import java.sql.Statement;
 
-import javax.servlet.ServletContext;
-
 import org.apache.log4j.Logger;
-import org.openbravo.base.ConnectionProviderContextListener;
 import org.openbravo.client.application.window.servlet.CalloutServletConfig;
 import org.openbravo.database.ConnectionProvider;
 import org.openbravo.exception.NoConnectionAvailableException;
+import org.openbravo.service.db.DalConnectionProvider;
 
 /**
  * A connection provider which is used on current SimpleCallout infrastructure 
(see
@@ -42,21 +40,16 @@
  * @author inigo.sanchez
  */
 public class DelegateConnectionProvider implements ConnectionProvider {
-
   protected ConnectionProvider myPool;
-  private ServletContext context;
   protected Logger log4j = Logger.getLogger(this.getClass());
 
   public void init(CalloutServletConfig config) {
-    context = config.getServletContext();
-    if (myPool == null) {
-      myPool = ConnectionProviderContextListener.getPool(context);
-    }
+    myPool = getPool();
   }
 
   private ConnectionProvider getPool() {
     if (myPool == null) {
-      myPool = ConnectionProviderContextListener.getPool(context);
+      myPool = new DalConnectionProvider(false);
     }
     return myPool;
   }

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Openbravo-commits mailing list
Openbravo-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to