Close connection after use in LiquibaseEndpoint

Update LiquibaseEndpoint so that connections are closed and returned to
the pool after use.

Fixes gh-6118
This commit is contained in:
Johannes Edmeier 2016-06-05 18:47:49 +02:00 committed by Phillip Webb
parent 452281ca8d
commit e89063cc07
1 changed files with 7 additions and 2 deletions

View File

@ -54,8 +54,13 @@ public class LiquibaseEndpoint extends AbstractEndpoint<List<Map<String, ?>>> {
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);