From 3498a91259f0b417674e5fe392f3c831fc2ce9b4 Mon Sep 17 00:00:00 2001 From: dmsergeevp44 Date: Sat, 23 Jun 2018 13:31:22 -0500 Subject: [PATCH] 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 --- .../boot/actuate/endpoint/LiquibaseEndpoint.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/LiquibaseEndpoint.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/LiquibaseEndpoint.java index 11b086f664..6136a09862 100644 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/LiquibaseEndpoint.java +++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/LiquibaseEndpoint.java @@ -38,6 +38,7 @@ import org.springframework.util.StringUtils; * {@link Endpoint} to expose liquibase info. * * @author EddĂș MelĂ©ndez + * @author Dmitrii Sergeev * @since 1.3.0 */ @ConfigurationProperties(prefix = "endpoints.liquibase") @@ -65,9 +66,9 @@ public class LiquibaseEndpoint extends AbstractEndpoint> { DataSource dataSource = entry.getValue().getDataSource(); JdbcConnection connection = new JdbcConnection( dataSource.getConnection()); + Database database = null; try { - Database database = factory - .findCorrectDatabaseImplementation(connection); + database = factory.findCorrectDatabaseImplementation(connection); String defaultSchema = entry.getValue().getDefaultSchema(); if (StringUtils.hasText(defaultSchema)) { database.setDefaultSchemaName(defaultSchema); @@ -76,7 +77,9 @@ public class LiquibaseEndpoint extends AbstractEndpoint> { service.queryDatabaseChangeLogTable(database))); } finally { - connection.close(); + if (database != null) { + database.close(); + } } } catch (Exception ex) {