Skip to content

DataSourceUtils does not respect c3p0 TimeoutException [SPR-7226] #11885

Closed
@spring-projects-issues

Description

@spring-projects-issues

Janning Vygen opened SPR-7226 and commented

See DataSourceUtils.prepareConnectionForTransaction(Connection con, TransactionDefinition definition)

In the catch Block every Exception is catched and silently dropped:

// Set read-only flag.
if (definition != null && definition.isReadOnly()) {
try {
if (logger.isDebugEnabled()) {
logger.debug("Setting JDBC Connection [" + con + "] read-only");
}
con.setReadOnly(true);
}
catch (Throwable ex) {
// SQLException or UnsupportedOperationException
// -> ignore, it's just a hint anyway.
logger.debug("Could not set JDBC Connection read-only", ex);
}
}

In the case where i have c3p0.checkoutTimeout set, it silently drops the TimeoutException here.

The TimeoutConnection get thrown when Hibernate trys to start a connection (in doBeginTransaction()). So when your database is overloaded and you have a timeout of 3 Seconds it takes an effective time of 6 seconds to get the exception, when your transaction isReadOnly(). This is annoying, when you really want to have a timeout of 3 seconds in all cases.


Affects: 3.0.2

Referenced from: commits 0c6b38b, 8800bab, d7f72fb

Metadata

Metadata

Assignees

Labels

in: dataIssues in data modules (jdbc, orm, oxm, tx)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions