Merge branch '1.5.x' into 2.0.x
This commit is contained in:
commit
911453d478
|
|
@ -80,8 +80,9 @@ public class LiquibaseEndpoint {
|
|||
try {
|
||||
DataSource dataSource = liquibase.getDataSource();
|
||||
JdbcConnection connection = new JdbcConnection(dataSource.getConnection());
|
||||
Database database = null;
|
||||
try {
|
||||
Database database = factory.findCorrectDatabaseImplementation(connection);
|
||||
database = factory.findCorrectDatabaseImplementation(connection);
|
||||
String defaultSchema = liquibase.getDefaultSchema();
|
||||
if (StringUtils.hasText(defaultSchema)) {
|
||||
database.setDefaultSchemaName(defaultSchema);
|
||||
|
|
@ -91,7 +92,12 @@ public class LiquibaseEndpoint {
|
|||
.map(ChangeSet::new).collect(Collectors.toList()));
|
||||
}
|
||||
finally {
|
||||
connection.close();
|
||||
if (database != null) {
|
||||
database.close();
|
||||
}
|
||||
else {
|
||||
connection.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex) {
|
||||
|
|
|
|||
|
|
@ -16,6 +16,11 @@
|
|||
|
||||
package org.springframework.boot.actuate.liquibase;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.boot.autoconfigure.AutoConfigurations;
|
||||
|
|
@ -62,6 +67,23 @@ public class LiquibaseEndpointTests {
|
|||
.hasSize(1));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void connectionAutoCommitPropertyIsReset() {
|
||||
this.contextRunner.withUserConfiguration(Config.class).run((context) -> {
|
||||
DataSource dataSource = context.getBean(DataSource.class);
|
||||
assertThat(getAutoCommit(dataSource)).isTrue();
|
||||
context.getBean(LiquibaseEndpoint.class).liquibaseBeans();
|
||||
assertThat(getAutoCommit(dataSource)).isTrue();
|
||||
});
|
||||
}
|
||||
|
||||
private boolean getAutoCommit(DataSource dataSource) throws SQLException {
|
||||
try (Connection connection = dataSource.getConnection()) {
|
||||
System.out.println(connection);
|
||||
return connection.getAutoCommit();
|
||||
}
|
||||
}
|
||||
|
||||
@Configuration
|
||||
public static class Config {
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue