You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@manifoldcf.apache.org by kw...@apache.org on 2010/07/21 15:15:15 UTC
svn commit: r966217 - in
/incubator/lcf/trunk/modules/framework/core/org/apache/lcf/core/database:
DBInterfaceDerby.java DBInterfacePostgreSQL.java
Author: kwright
Date: Wed Jul 21 13:15:14 2010
New Revision: 966217
URL: http://svn.apache.org/viewvc?rev=966217&view=rev
Log:
Revise database error reinterpretation to use SQLState abstraction, rather than looking at text. Text lookup was failing on non-English systems.
Modified:
incubator/lcf/trunk/modules/framework/core/org/apache/lcf/core/database/DBInterfaceDerby.java
incubator/lcf/trunk/modules/framework/core/org/apache/lcf/core/database/DBInterfacePostgreSQL.java
Modified: incubator/lcf/trunk/modules/framework/core/org/apache/lcf/core/database/DBInterfaceDerby.java
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/modules/framework/core/org/apache/lcf/core/database/DBInterfaceDerby.java?rev=966217&r1=966216&r2=966217&view=diff
==============================================================================
--- incubator/lcf/trunk/modules/framework/core/org/apache/lcf/core/database/DBInterfaceDerby.java (original)
+++ incubator/lcf/trunk/modules/framework/core/org/apache/lcf/core/database/DBInterfaceDerby.java Wed Jul 21 13:15:14 2010
@@ -589,13 +589,16 @@ public class DBInterfaceDerby extends Da
return theException;
if (Logging.db.isDebugEnabled())
Logging.db.debug("Exception "+theException.getMessage()+" is possibly a transaction abort signal");
- String message = e.getMessage();
- if (message.indexOf("due to a deadlock") != -1)
- return new LCFException(message,e,LCFException.DATABASE_TRANSACTION_ABORT);
+ java.sql.SQLException sqlException = (java.sql.SQLException)e;
+ String message = sqlException.getMessage();
+ String sqlState = sqlException.getSQLState();
// Note well: We also have to treat 'duplicate key' as a transaction abort, since this is what you get when two threads attempt to
// insert the same row. (Everything only works, then, as long as there is a unique constraint corresponding to every bad insert that
// one could make.)
- if (message.indexOf("duplicate key") != -1)
+ if (sqlState != null && sqlState.equals("23505"))
+ return new LCFException(message,e,LCFException.DATABASE_TRANSACTION_ABORT);
+ // Deadlock also aborts.
+ if (sqlState != null && sqlState.equals("40001"))
return new LCFException(message,e,LCFException.DATABASE_TRANSACTION_ABORT);
if (Logging.db.isDebugEnabled())
Logging.db.debug("Exception "+theException.getMessage()+" is NOT a transaction abort signal");
Modified: incubator/lcf/trunk/modules/framework/core/org/apache/lcf/core/database/DBInterfacePostgreSQL.java
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/modules/framework/core/org/apache/lcf/core/database/DBInterfacePostgreSQL.java?rev=966217&r1=966216&r2=966217&view=diff
==============================================================================
--- incubator/lcf/trunk/modules/framework/core/org/apache/lcf/core/database/DBInterfacePostgreSQL.java (original)
+++ incubator/lcf/trunk/modules/framework/core/org/apache/lcf/core/database/DBInterfacePostgreSQL.java Wed Jul 21 13:15:14 2010
@@ -554,15 +554,19 @@ public class DBInterfacePostgreSQL exten
return theException;
if (Logging.db.isDebugEnabled())
Logging.db.debug("Exception "+theException.getMessage()+" is possibly a transaction abort signal");
- String message = e.getMessage();
- if (message.indexOf("deadlock detected") != -1)
+ java.sql.SQLException sqlException = (java.sql.SQLException)e;
+ String message = sqlException.getMessage();
+ String sqlState = sqlException.getSQLState();
+ // Could not serialize
+ if (sqlState != null && sqlState.equals("40001"))
return new LCFException(message,e,LCFException.DATABASE_TRANSACTION_ABORT);
- if (message.indexOf("could not serialize") != -1)
+ // Deadlock detected
+ if (sqlState != null && sqlState.equals("40P01"))
return new LCFException(message,e,LCFException.DATABASE_TRANSACTION_ABORT);
// Note well: We also have to treat 'duplicate key' as a transaction abort, since this is what you get when two threads attempt to
// insert the same row. (Everything only works, then, as long as there is a unique constraint corresponding to every bad insert that
// one could make.)
- if (message.indexOf("duplicate key") != -1)
+ if (sqlState != null && sqlState.equals("23505"))
return new LCFException(message,e,LCFException.DATABASE_TRANSACTION_ABORT);
if (Logging.db.isDebugEnabled())
Logging.db.debug("Exception "+theException.getMessage()+" is NOT a transaction abort signal");