Open
Description
private void openConnection() throws SQLException {
this.connection = DataSourceUtils.getConnection(this.dataSource);
this.autoCommit = this.connection.getAutoCommit();
this.isConnectionTransactional = DataSourceUtils.isConnectionTransactional(this.connection, this.dataSource);
LOGGER.debug(() -> "JDBC Connection [" + this.connection + "] will"
+ (this.isConnectionTransactional ? " " : " not ") + "be managed by Spring");
}
In the SpringManagedTransaction.openConnection() method, if line 80 creates a new database connection, the conditional check at line 81 will always evaluate to true. This occurs because the newly created connection is already stored in threadlocal storage during the preceding steps. As a result, line 82 will log that the connection is "managed by Spring transactions", even though this connection is actually a fresh instance created outside Spring's transactional context and remains separate from the actual Spring-managed transactional connection.
version: 2.0.7
Metadata
Metadata
Assignees
Labels
No labels