openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dwo...@apache.org
Subject svn commit: r932068 - /openjpa/branches/2.0.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/MySQLDictionary.java
Date Thu, 08 Apr 2010 19:17:54 GMT
Author: dwoods
Date: Thu Apr  8 19:17:53 2010
New Revision: 932068

URL: http://svn.apache.org/viewvc?rev=932068&view=rev
Log:
OPENJPA-1616 Fix TestTimeoutException test failures on MySQL

Modified:
    openjpa/branches/2.0.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/MySQLDictionary.java

Modified: openjpa/branches/2.0.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/MySQLDictionary.java
URL: http://svn.apache.org/viewvc/openjpa/branches/2.0.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/MySQLDictionary.java?rev=932068&r1=932067&r2=932068&view=diff
==============================================================================
--- openjpa/branches/2.0.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/MySQLDictionary.java
(original)
+++ openjpa/branches/2.0.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/MySQLDictionary.java
Thu Apr  8 19:17:53 2010
@@ -27,6 +27,7 @@ import java.util.Arrays;
 import java.util.Collection;
 import java.util.HashSet;
 import java.util.List;
+import java.util.Map;
 import java.util.Set;
 
 import org.apache.commons.lang.StringUtils;
@@ -423,6 +424,24 @@ public class MySQLDictionary
     }
     
     @Override
+    protected int matchErrorState(Map<Integer,Set<String>> errorStates, SQLException
ex) {
+        int state = super.matchErrorState(errorStates, ex);
+        // OPENJPA-1616 - Special case for MySQL not returning a SQLState for timeouts
+        if (state == StoreException.GENERAL && ex.getErrorCode() == 0 &&
ex.getSQLState() == null) {
+            // look at the nested MySQL exception for more details
+            SQLException sqle = ex.getNextException();
+            if (sqle != null && sqle.toString().startsWith("com.mysql.jdbc.exceptions.MySQLTimeoutException"))
{
+                if (conf != null && conf.getLockTimeout() != -1) {
+                    state = StoreException.LOCK;
+                } else {
+                    state = StoreException.QUERY;
+                }
+            }
+        }
+        return state;
+    }
+
+    @Override
     public boolean isFatalException(int subtype, SQLException ex) {
         if ((subtype == StoreException.LOCK  && ex.getErrorCode() == 1205)
           ||(subtype == StoreException.QUERY && ex.getErrorCode() == 1317)) {



Mime
View raw message