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()
|
DriverManager.getConnection(conf.getConnectionURL()
|
||||||
+ ";shutdown=true");
|
+ ";shutdown=true");
|
||||||
} catch (SQLException e) {
|
} 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
|
// Derby strangely uses that as a mechanism to report
|
||||||
// a successful shutdown
|
// a successful shutdown
|
||||||
}
|
}
|
||||||
|
@ -143,19 +143,13 @@ public class DerbyDictionary
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Boolean matchErrorState(int subtype, Set<String> errorStates,
|
protected boolean isFatalException(int subtype, SQLException ex) {
|
||||||
SQLException ex) {
|
|
||||||
Boolean recoverable = null;
|
|
||||||
String errorState = ex.getSQLState();
|
|
||||||
int errorCode = ex.getErrorCode();
|
int errorCode = ex.getErrorCode();
|
||||||
if (errorStates.contains(errorState)) {
|
if ((subtype == StoreException.LOCK ||
|
||||||
recoverable = Boolean.FALSE;
|
subtype == StoreException.QUERY) && errorCode <= 30000) {
|
||||||
if ((subtype == StoreException.LOCK ||
|
return false;
|
||||||
subtype == StoreException.QUERY) && errorCode < 30000) {
|
|
||||||
recoverable = Boolean.TRUE;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return recoverable;
|
return super.isFatalException(subtype, ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,7 @@ import java.sql.SQLException;
|
||||||
import java.sql.Types;
|
import java.sql.Types;
|
||||||
import java.text.MessageFormat;
|
import java.text.MessageFormat;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
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.jdbc.schema.Unique;
|
||||||
import org.apache.openjpa.lib.identifier.IdentifierUtil;
|
import org.apache.openjpa.lib.identifier.IdentifierUtil;
|
||||||
import org.apache.openjpa.lib.util.Localizer;
|
import org.apache.openjpa.lib.util.Localizer;
|
||||||
|
import org.apache.openjpa.util.StoreException;
|
||||||
import org.apache.openjpa.util.UnsupportedException;
|
import org.apache.openjpa.util.UnsupportedException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -482,10 +484,12 @@ public class FirebirdDictionary
|
||||||
* Use error code as SQL state returned by Firebird is ambiguous.
|
* Use error code as SQL state returned by Firebird is ambiguous.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected Boolean matchErrorState(int subtype, Set<String> errorStates,
|
protected int matchErrorState(Map<Integer,Set<String>> errorStates, SQLException ex) {
|
||||||
SQLException ex) {
|
String errorState = ""+ex.getErrorCode();
|
||||||
int errorCode = ex.getErrorCode();
|
for (Map.Entry<Integer,Set<String>> states : errorStates.entrySet()) {
|
||||||
return errorStates.contains(String.valueOf(errorCode)) ? Boolean.FALSE
|
if (states.getValue().contains(errorState))
|
||||||
: null;
|
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.Index;
|
||||||
import org.apache.openjpa.jdbc.schema.PrimaryKey;
|
import org.apache.openjpa.jdbc.schema.PrimaryKey;
|
||||||
import org.apache.openjpa.jdbc.schema.Table;
|
import org.apache.openjpa.jdbc.schema.Table;
|
||||||
|
import org.apache.openjpa.util.StoreException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dictionary for MySQL.
|
* Dictionary for MySQL.
|
||||||
|
@ -420,6 +421,15 @@ public class MySQLDictionary
|
||||||
}
|
}
|
||||||
return result;
|
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,
|
* OPENJPA-740 Special case for MySql special column types,
|
||||||
|
@ -443,6 +453,5 @@ public class MySQLDictionary
|
||||||
return super.getTypeName(col);
|
return super.getTypeName(col);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -281,20 +281,12 @@ public class SQLServerDictionary extends AbstractSQLServerDictionary {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Boolean matchErrorState(int subtype, Set<String> errorStates,
|
protected boolean isFatalException(int subtype, SQLException ex) {
|
||||||
SQLException ex) {
|
|
||||||
Boolean recoverable = null;
|
|
||||||
String errorState = ex.getSQLState();
|
String errorState = ex.getSQLState();
|
||||||
if (errorStates.contains(errorState)) {
|
if ((subtype == StoreException.LOCK && "1222".equals(errorState))
|
||||||
recoverable = Boolean.FALSE;
|
||(subtype == StoreException.QUERY && "HY008".equals(errorState)))
|
||||||
if (subtype == StoreException.LOCK && errorState.equals("1222")) {
|
return false;
|
||||||
recoverable = Boolean.TRUE;
|
return super.isFatalException(subtype, ex);
|
||||||
} else if (subtype == StoreException.QUERY &&
|
|
||||||
errorState.equals("HY008")) {
|
|
||||||
recoverable = Boolean.TRUE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return recoverable;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -719,13 +719,14 @@ public class FetchConfigurationImpl
|
||||||
} else if ("setWriteLockLevel".equals(methodName) && !isActiveTransaction()) {
|
} else if ("setWriteLockLevel".equals(methodName) && !isActiveTransaction()) {
|
||||||
_state.writeLockLevel = (Integer)value;
|
_state.writeLockLevel = (Integer)value;
|
||||||
} else {
|
} else {
|
||||||
setter.invoke(this, value);
|
setter.invoke(this, Filters.convertToMatchMethodArgument(value, setter));
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
if (e instanceof IllegalArgumentException)
|
String message = _loc.get("bad-hint-value", key, toString(value), toString(original)).getMessage();
|
||||||
throw (IllegalArgumentException)e;
|
if (e instanceof IllegalArgumentException) {
|
||||||
throw new IllegalArgumentException(_loc.get("bad-hint-value", key, toString(value),
|
throw new IllegalArgumentException(message);
|
||||||
toString(original)).getMessage(), e);
|
}
|
||||||
|
throw new IllegalArgumentException(message, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
addHint(key, original);
|
addHint(key, original);
|
||||||
|
|
|
@ -272,4 +272,13 @@ public class Exceptions {
|
||||||
return toClassName(cls.getComponentType())+"[]";
|
return toClassName(cls.getComponentType())+"[]";
|
||||||
return cls.getName();
|
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