OPENJPA-1616 Fix TestTimeoutException test failures on MySQL

git-svn-id: https://svn.apache.org/repos/asf/openjpa/branches/2.0.x@932068 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Donald Woods 2010-04-08 19:17:53 +00:00
parent bb8ef003ac
commit 366406216f
1 changed files with 19 additions and 0 deletions

View File

@ -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;
@ -422,6 +423,24 @@ public class MySQLDictionary
return result;
}
@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)