mirror of https://github.com/apache/openjpa.git
OPENJPA-1565: Raise correct timeout exceptions.
git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@922290 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
4be5a5a194
commit
f04031edc1
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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.Sequence;
|
|||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,6 +39,7 @@ import org.apache.openjpa.jdbc.schema.ForeignKey;
|
|||
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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -281,20 +281,12 @@ public class SQLServerDictionary extends AbstractSQLServerDictionary {
|
|||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue