From e89063cc073de91f29c733fdffb22517201f33b6 Mon Sep 17 00:00:00 2001 From: Johannes Edmeier Date: Sun, 5 Jun 2016 18:47:49 +0200 Subject: [PATCH] Close connection after use in LiquibaseEndpoint Update LiquibaseEndpoint so that connections are closed and returned to the pool after use. Fixes gh-6118 --- .../boot/actuate/endpoint/LiquibaseEndpoint.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 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 796beb373e6..132567fb6dd 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 @@ -54,8 +54,13 @@ public class LiquibaseEndpoint extends AbstractEndpoint>> { DatabaseFactory factory = DatabaseFactory.getInstance(); DataSource dataSource = this.liquibase.getDataSource(); JdbcConnection connection = new JdbcConnection(dataSource.getConnection()); - Database database = factory.findCorrectDatabaseImplementation(connection); - return service.queryDatabaseChangeLogTable(database); + try { + Database database = factory.findCorrectDatabaseImplementation(connection); + return service.queryDatabaseChangeLogTable(database); + } + finally { + connection.close(); + } } catch (Exception ex) { throw new IllegalStateException("Unable to get Liquibase changelog", ex);