Skip to content

Commit e89063c

Browse files
joshistephilwebb
authored andcommitted
Close connection after use in LiquibaseEndpoint
Update LiquibaseEndpoint so that connections are closed and returned to the pool after use. Fixes gh-6118
1 parent 452281c commit e89063c

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,13 @@ public LiquibaseEndpoint(SpringLiquibase liquibase) {
5454
DatabaseFactory factory = DatabaseFactory.getInstance();
5555
DataSource dataSource = this.liquibase.getDataSource();
5656
JdbcConnection connection = new JdbcConnection(dataSource.getConnection());
57-
Database database = factory.findCorrectDatabaseImplementation(connection);
58-
return service.queryDatabaseChangeLogTable(database);
57+
try {
58+
Database database = factory.findCorrectDatabaseImplementation(connection);
59+
return service.queryDatabaseChangeLogTable(database);
60+
}
61+
finally {
62+
connection.close();
63+
}
5964
}
6065
catch (Exception ex) {
6166
throw new IllegalStateException("Unable to get Liquibase changelog", ex);

0 commit comments

Comments
 (0)