openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ppod...@apache.org
Subject svn commit: r922290 - in /openjpa/trunk: openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/ openjpa-kernel/src/main/java/org/apache/openjpa/kernel/ openjpa-kernel/src/main/java/org/apache/openjpa/util/
Date Fri, 12 Mar 2010 15:17:59 GMT
Author: ppoddar
Date: Fri Mar 12 15:17:58 2010
New Revision: 922290

URL: http://svn.apache.org/viewvc?rev=922290&view=rev
Log:
OPENJPA-1565: Raise correct timeout exceptions.

Modified:
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DerbyDictionary.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/FirebirdDictionary.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/MySQLDictionary.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SQLServerDictionary.java
    openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/FetchConfigurationImpl.java
    openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/Exceptions.java

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DerbyDictionary.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DerbyDictionary.java?rev=922290&r1=922289&r2=922290&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DerbyDictionary.java
(original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DerbyDictionary.java
Fri Mar 12 15:17:58 2010
@@ -135,7 +135,7 @@ public class DerbyDictionary
                 DriverManager.getConnection(conf.getConnectionURL()
                     + ";shutdown=true");
             } catch (SQLException e) {
-                // we actuall expect a SQLException to be thrown here:
+                // we actually expect a SQLException to be thrown here:
                 // Derby strangely uses that as a mechanism to report
                 // a successful shutdown
             }
@@ -143,19 +143,13 @@ public class DerbyDictionary
     }
     
     @Override
-    protected Boolean matchErrorState(int subtype, Set<String> errorStates,
-        SQLException ex) {
-        Boolean recoverable = null;
-        String errorState = ex.getSQLState();
+    protected boolean isFatalException(int subtype, SQLException ex) {
         int errorCode = ex.getErrorCode();
-        if (errorStates.contains(errorState)) {
-            recoverable = Boolean.FALSE;
-            if ((subtype == StoreException.LOCK ||
-                    subtype == StoreException.QUERY) && errorCode < 30000) {
-                recoverable = Boolean.TRUE;
-            }
+        if ((subtype == StoreException.LOCK ||
+             subtype == StoreException.QUERY) && errorCode <= 30000) {
+            return false;
         }
-        return recoverable;
+        return super.isFatalException(subtype, ex);
     }
 
 }

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/FirebirdDictionary.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/FirebirdDictionary.java?rev=922290&r1=922289&r2=922290&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/FirebirdDictionary.java
(original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/FirebirdDictionary.java
Fri Mar 12 15:17:58 2010
@@ -25,6 +25,7 @@ import java.sql.SQLException;
 import java.sql.Types;
 import java.text.MessageFormat;
 import java.util.Arrays;
+import java.util.Map;
 import java.util.Set;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
@@ -38,6 +39,7 @@ import org.apache.openjpa.jdbc.schema.Se
 import org.apache.openjpa.jdbc.schema.Unique;
 import org.apache.openjpa.lib.identifier.IdentifierUtil;
 import org.apache.openjpa.lib.util.Localizer;
+import org.apache.openjpa.util.StoreException;
 import org.apache.openjpa.util.UnsupportedException;
 
 /**
@@ -482,10 +484,12 @@ public class FirebirdDictionary
      * Use error code as SQL state returned by Firebird is ambiguous.
      */
     @Override
-    protected Boolean matchErrorState(int subtype, Set<String> errorStates,
-        SQLException ex) {
-        int errorCode = ex.getErrorCode();
-        return errorStates.contains(String.valueOf(errorCode)) ? Boolean.FALSE
-            : null;
+    protected int matchErrorState(Map<Integer,Set<String>> errorStates, SQLException
ex) {
+        String errorState = ""+ex.getErrorCode();
+        for (Map.Entry<Integer,Set<String>> states : errorStates.entrySet())
{
+            if (states.getValue().contains(errorState))
+                return states.getKey();
+        }
+        return StoreException.GENERAL;
     }
 }

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/MySQLDictionary.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/MySQLDictionary.java?rev=922290&r1=922289&r2=922290&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/MySQLDictionary.java
(original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/MySQLDictionary.java
Fri Mar 12 15:17:58 2010
@@ -39,6 +39,7 @@ import org.apache.openjpa.jdbc.schema.Fo
 import org.apache.openjpa.jdbc.schema.Index;
 import org.apache.openjpa.jdbc.schema.PrimaryKey;
 import org.apache.openjpa.jdbc.schema.Table;
+import org.apache.openjpa.util.StoreException;
 
 /**
  * Dictionary for MySQL.
@@ -420,6 +421,15 @@ public class MySQLDictionary
         }
         return result;
     }
+    
+    @Override
+    protected boolean isFatalException(int subtype, SQLException ex) {
+        if ((subtype == StoreException.LOCK  && ex.getErrorCode() == 1205)
+          ||(subtype == StoreException.QUERY && ex.getErrorCode() == 1317)) {
+            return false;
+        }
+        return super.isFatalException(subtype, ex);
+    }
 
     /**
      * OPENJPA-740 Special case for MySql special column types,
@@ -443,6 +453,5 @@ public class MySQLDictionary
             return super.getTypeName(col);
         }
     }
-
 }
 

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SQLServerDictionary.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SQLServerDictionary.java?rev=922290&r1=922289&r2=922290&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SQLServerDictionary.java
(original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SQLServerDictionary.java
Fri Mar 12 15:17:58 2010
@@ -281,20 +281,12 @@ public class SQLServerDictionary extends
     }
     
     @Override
-    protected Boolean matchErrorState(int subtype, Set<String> errorStates,
-        SQLException ex) {
-        Boolean recoverable = null;
+    protected boolean isFatalException(int subtype,  SQLException ex) {
         String errorState = ex.getSQLState();
-        if (errorStates.contains(errorState)) {
-            recoverable = Boolean.FALSE;
-            if (subtype == StoreException.LOCK && errorState.equals("1222")) {
-                recoverable = Boolean.TRUE;
-            } else if (subtype == StoreException.QUERY &&
-                errorState.equals("HY008")) {
-                recoverable = Boolean.TRUE;
-            }
-        }
-        return recoverable;
+        if ((subtype == StoreException.LOCK  && "1222".equals(errorState))
+          ||(subtype == StoreException.QUERY && "HY008".equals(errorState)))
+         return false;
+        return super.isFatalException(subtype, ex);
     }
 
     /**

Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/FetchConfigurationImpl.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/FetchConfigurationImpl.java?rev=922290&r1=922289&r2=922290&view=diff
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/FetchConfigurationImpl.java
(original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/FetchConfigurationImpl.java
Fri Mar 12 15:17:58 2010
@@ -719,13 +719,14 @@ public class FetchConfigurationImpl
                 } else if ("setWriteLockLevel".equals(methodName) && !isActiveTransaction())
{
                     _state.writeLockLevel = (Integer)value;
                 } else {
-                    setter.invoke(this, value);
+                    setter.invoke(this, Filters.convertToMatchMethodArgument(value, setter));
                 }
             } catch (Exception e) {
-                if (e instanceof IllegalArgumentException)
-                    throw (IllegalArgumentException)e;
-                throw new IllegalArgumentException(_loc.get("bad-hint-value", key, toString(value),

-                        toString(original)).getMessage(), e);
+                String message = _loc.get("bad-hint-value", key, toString(value), toString(original)).getMessage();
+                if (e instanceof IllegalArgumentException) {
+                    throw new IllegalArgumentException(message);
+                }
+                throw new IllegalArgumentException(message, e);
             }
         }
         addHint(key, original);

Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/Exceptions.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/Exceptions.java?rev=922290&r1=922289&r2=922290&view=diff
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/Exceptions.java (original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/Exceptions.java Fri
Mar 12 15:17:58 2010
@@ -272,4 +272,13 @@ public class Exceptions {
             return toClassName(cls.getComponentType())+"[]";
         return cls.getName();
     }
+    
+    public static String toClassNames(Collection<? extends Class<?>> classes)
{
+        if (classes == null) return "";
+        StringBuilder buffer = new StringBuilder();
+        for (Class<?> cls : classes) {
+            buffer.append("\r\n").append(toClassName(cls));
+        }
+        return buffer.toString();
+    }
 }



Mime
View raw message