You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by re...@apache.org on 2015/06/03 10:29:36 UTC

svn commit: r1683253 - in /jackrabbit/oak/branches/1.2: ./ oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBConnectionHandler.java

Author: reschke
Date: Wed Jun  3 08:29:35 2015
New Revision: 1683253

URL: http://svn.apache.org/r1683253
Log:
OAK-2952 - RDBConnectionHandler: log failures on setReadOnly() only once (ported to 1.2)

Modified:
    jackrabbit/oak/branches/1.2/   (props changed)
    jackrabbit/oak/branches/1.2/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBConnectionHandler.java

Propchange: jackrabbit/oak/branches/1.2/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Jun  3 08:29:35 2015
@@ -1,3 +1,3 @@
 /jackrabbit/oak/branches/1.0:1665962
-/jackrabbit/oak/trunk:1672350,1672468,1672537,1672603,1672642,1672644,1672834-1672835,1673351,1673410,1673414,1673436,1673644,1673662-1673664,1673669,1673695,1674046,1674065,1674075,1674107,1674228,1674880,1675054-1675055,1675332,1675354,1675357,1675382,1675555,1675566,1675593,1676198,1676237,1676407,1676458,1676539,1676670,1676693,1676703,1676725,1677579,1677581,1677609,1677611,1677774,1677939,1677991,1678173,1678323,1678758,1678938,1678954,1679144,1679165,1679191,1679235,1680182,1680222,1680232,1680236,1680461,1680633,1680643,1680805-1680806,1680903,1681282,1681767,1681918,1682218,1682235,1682437,1682494,1682855,1682904,1683089,1683213
+/jackrabbit/oak/trunk:1672350,1672468,1672537,1672603,1672642,1672644,1672834-1672835,1673351,1673410,1673414,1673436,1673644,1673662-1673664,1673669,1673695,1674046,1674065,1674075,1674107,1674228,1674880,1675054-1675055,1675332,1675354,1675357,1675382,1675555,1675566,1675593,1676198,1676237,1676407,1676458,1676539,1676670,1676693,1676703,1676725,1677579,1677581,1677609,1677611,1677774,1677939,1677991,1678173,1678323,1678758,1678938,1678954,1679144,1679165,1679191,1679235,1680182,1680222,1680232,1680236,1680461,1680633,1680643,1680805-1680806,1680903,1681282,1681767,1681918,1682218,1682235,1682437,1682494,1682855,1682904,1683089,1683213,1683249
 /jackrabbit/trunk:1345480

Modified: jackrabbit/oak/branches/1.2/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBConnectionHandler.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.2/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBConnectionHandler.java?rev=1683253&r1=1683252&r2=1683253&view=diff
==============================================================================
--- jackrabbit/oak/branches/1.2/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBConnectionHandler.java (original)
+++ jackrabbit/oak/branches/1.2/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBConnectionHandler.java Wed Jun  3 08:29:35 2015
@@ -164,24 +164,39 @@ public class RDBConnectionHandler implem
     // workaround for broken connection wrappers
     // see https://issues.apache.org/jira/browse/OAK-2918
 
-    private Boolean setReadOnlyThrows = null;    // null if we haven't checked yet
-    private Boolean setReadWriteThrows = null;    // null if we haven't checked yet
+    private Boolean setReadOnlyThrows = null; // null if we haven't checked yet
+    private Boolean setReadWriteThrows = null; // null if we haven't checked yet
 
     private void setReadOnly(Connection c, boolean ro) throws SQLException {
 
-        Boolean flag = ro ? setReadOnlyThrows : setReadWriteThrows;
-
-        if (flag == null) {
-            // we don't know yet, so we try once
-            try {
-                c.setReadOnly(ro);
-                flag = Boolean.FALSE;
-            } catch (SQLException ex) {
-                flag = Boolean.TRUE;
-                LOG.error("Connection " + c.getClass() + " throws SQLException on setReadOnly(" + ro + "); not trying again");
+        if (ro) {
+            if (this.setReadOnlyThrows == null) {
+                // we don't know yet, so we try at least once
+                try {
+                    c.setReadOnly(true);
+                    this.setReadOnlyThrows = Boolean.FALSE;
+                } catch (SQLException ex) {
+                    LOG.error("Connection class " + c.getClass()
+                            + " erroneously throws SQLException on setReadOnly(true); not trying again");
+                    this.setReadOnlyThrows = Boolean.TRUE;
+                }
+            } else if (!this.setReadOnlyThrows) {
+                c.setReadOnly(true);
+            }
+        } else {
+            if (this.setReadWriteThrows == null) {
+                // we don't know yet, so we try at least once
+                try {
+                    c.setReadOnly(false);
+                    this.setReadWriteThrows = Boolean.FALSE;
+                } catch (SQLException ex) {
+                    LOG.error("Connection class " + c.getClass()
+                            + " erroneously throws SQLException on setReadOnly(false); not trying again");
+                    this.setReadWriteThrows = Boolean.TRUE;
+                }
+            } else if (!this.setReadWriteThrows) {
+                c.setReadOnly(false);
             }
-        } else if (!flag) {
-            c.setReadOnly(ro);
         }
     }
 }