From be285084f9251aee7da50733278652fc98797ed9 Mon Sep 17 00:00:00 2001 From: Heng Sin Low Date: Fri, 21 Mar 2008 01:20:34 +0000 Subject: [PATCH] * [1921799] - disable reaonly optimization * Added autocommit checking, failure to set autocommit on connection is very dangerous. --- base/src/org/compiere/util/DB.java | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/base/src/org/compiere/util/DB.java b/base/src/org/compiere/util/DB.java index 575df0bc9e..8fa055abb5 100644 --- a/base/src/org/compiere/util/DB.java +++ b/base/src/org/compiere/util/DB.java @@ -419,6 +419,15 @@ public final class DB } **/ } + + //hengsin: failed to set autocommit can lead to severe lock up of the system + try { + if (conn != null && conn.getAutoCommit() != autoCommit) + { + throw new IllegalStateException("Failed to set the requested auto commit mode on connection. [autoCommit=" + autoCommit +"]"); + } + } catch (SQLException e) {} + return conn; } // createConnection @@ -438,6 +447,8 @@ public final class DB Connection conn = s_cc.getConnection (autoCommit, trxLevel); + //hengsin: this could be problematic as it can be reuse for readwrite activites after return to pool + /* if (conn != null) { try @@ -449,12 +460,20 @@ public final class DB conn = null; log.log(Level.SEVERE, ex.getMessage(), ex); } - } + }*/ if (conn == null) { throw new IllegalStateException("DB.getConnectionRO - @NoDBConnection@"); } + + //hengsin: failed to set autocommit can lead to severe lock up of the system + try { + if (conn.getAutoCommit() != autoCommit) + { + throw new IllegalStateException("Failed to set the requested auto commit mode on connection. [autocommit=" + autoCommit +"]"); + } + } catch (SQLException e) {} return conn; } // createConnection