DataSourceUtils lets timeout exceptions through even for setReadOnly calls (SPR-7226)
This commit is contained in:
parent
2676771255
commit
d7f72fbbd4
|
|
@ -51,8 +51,7 @@ import org.springframework.util.Assert;
|
||||||
public abstract class DataSourceUtils {
|
public abstract class DataSourceUtils {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Order value for TransactionSynchronization objects that clean up
|
* Order value for TransactionSynchronization objects that clean up JDBC Connections.
|
||||||
* JDBC Connections.
|
|
||||||
*/
|
*/
|
||||||
public static final int CONNECTION_SYNCHRONIZATION_ORDER = 1000;
|
public static final int CONNECTION_SYNCHRONIZATION_ORDER = 1000;
|
||||||
|
|
||||||
|
|
@ -156,7 +155,12 @@ public abstract class DataSourceUtils {
|
||||||
con.setReadOnly(true);
|
con.setReadOnly(true);
|
||||||
}
|
}
|
||||||
catch (Throwable ex) {
|
catch (Throwable ex) {
|
||||||
// SQLException or UnsupportedOperationException
|
if (ex instanceof SQLException && (ex.getClass().getSimpleName().contains("Timeout") ||
|
||||||
|
(ex.getCause() != null && ex.getCause().getClass().getSimpleName().contains("Timeout")))) {
|
||||||
|
// Assume it's a connection timeout that would otherwise get lost: e.g. from C3P0.
|
||||||
|
throw (SQLException) ex;
|
||||||
|
}
|
||||||
|
// "read-only not supported" SQLException or UnsupportedOperationException
|
||||||
// -> ignore, it's just a hint anyway.
|
// -> ignore, it's just a hint anyway.
|
||||||
logger.debug("Could not set JDBC Connection read-only", ex);
|
logger.debug("Could not set JDBC Connection read-only", ex);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue