Skip to content

Commit 3498a91

Browse files
dmsergeevp44wilkinsona
authored andcommitted
Close Database to reset Connection's auto commit property
Previously, LiquibaseEndpoint closed the JdbcConnection but did not close the Database. When using a connection pool, this could leave the underlying SQL Connection with its auto commit property set to false. This commit updates LiquibaseEndpoint to close the Database. This ensures that it resets that Connection's auto commit property to the value that it had when the Database was configured to use the Connection. See gh-13559
1 parent f32c66d commit 3498a91

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/LiquibaseEndpoint.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
* {@link Endpoint} to expose liquibase info.
3939
*
4040
* @author Eddú Meléndez
41+
* @author Dmitrii Sergeev
4142
* @since 1.3.0
4243
*/
4344
@ConfigurationProperties(prefix = "endpoints.liquibase")
@@ -65,9 +66,9 @@ public List<LiquibaseReport> invoke() {
6566
DataSource dataSource = entry.getValue().getDataSource();
6667
JdbcConnection connection = new JdbcConnection(
6768
dataSource.getConnection());
69+
Database database = null;
6870
try {
69-
Database database = factory
70-
.findCorrectDatabaseImplementation(connection);
71+
database = factory.findCorrectDatabaseImplementation(connection);
7172
String defaultSchema = entry.getValue().getDefaultSchema();
7273
if (StringUtils.hasText(defaultSchema)) {
7374
database.setDefaultSchemaName(defaultSchema);
@@ -76,7 +77,9 @@ public List<LiquibaseReport> invoke() {
7677
service.queryDatabaseChangeLogTable(database)));
7778
}
7879
finally {
79-
connection.close();
80+
if (database != null) {
81+
database.close();
82+
}
8083
}
8184
}
8285
catch (Exception ex) {

0 commit comments

Comments
 (0)