Commit e89063cc authored by Johannes Edmeier's avatar Johannes Edmeier Committed by Phillip Webb

Close connection after use in LiquibaseEndpoint

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

Fixes gh-6118
parent 452281ca
...@@ -54,9 +54,14 @@ public class LiquibaseEndpoint extends AbstractEndpoint<List<Map<String, ?>>> { ...@@ -54,9 +54,14 @@ public class LiquibaseEndpoint extends AbstractEndpoint<List<Map<String, ?>>> {
DatabaseFactory factory = DatabaseFactory.getInstance(); DatabaseFactory factory = DatabaseFactory.getInstance();
DataSource dataSource = this.liquibase.getDataSource(); DataSource dataSource = this.liquibase.getDataSource();
JdbcConnection connection = new JdbcConnection(dataSource.getConnection()); JdbcConnection connection = new JdbcConnection(dataSource.getConnection());
try {
Database database = factory.findCorrectDatabaseImplementation(connection); Database database = factory.findCorrectDatabaseImplementation(connection);
return service.queryDatabaseChangeLogTable(database); return service.queryDatabaseChangeLogTable(database);
} }
finally {
connection.close();
}
}
catch (Exception ex) { catch (Exception ex) {
throw new IllegalStateException("Unable to get Liquibase changelog", ex); throw new IllegalStateException("Unable to get Liquibase changelog", ex);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment