Merge branch '1.5.x'
This commit is contained in:
@@ -115,18 +115,14 @@ public class LiquibaseAutoConfiguration {
|
||||
}
|
||||
|
||||
private SpringLiquibase createSpringLiquibase() {
|
||||
SpringLiquibase liquibase;
|
||||
DataSource dataSourceToUse = getDataSource();
|
||||
if (dataSourceToUse == null) {
|
||||
dataSourceToUse = DataSourceBuilder.create().url(this.properties.getUrl())
|
||||
.username(this.properties.getUser())
|
||||
.password(this.properties.getPassword()).build();
|
||||
liquibase = new DataSourceClosingSpringLiquibase();
|
||||
DataSource liquibaseDataSource = getDataSource();
|
||||
if (liquibaseDataSource != null) {
|
||||
SpringLiquibase liquibase = new SpringLiquibase();
|
||||
liquibase.setDataSource(liquibaseDataSource);
|
||||
return liquibase;
|
||||
}
|
||||
else {
|
||||
liquibase = new SpringLiquibase();
|
||||
}
|
||||
liquibase.setDataSource(dataSourceToUse);
|
||||
SpringLiquibase liquibase = new DataSourceClosingSpringLiquibase();
|
||||
liquibase.setDataSource(createNewDataSource());
|
||||
return liquibase;
|
||||
}
|
||||
|
||||
@@ -134,12 +130,18 @@ public class LiquibaseAutoConfiguration {
|
||||
if (this.liquibaseDataSource != null) {
|
||||
return this.liquibaseDataSource;
|
||||
}
|
||||
else if (this.properties.getUrl() == null) {
|
||||
if (this.properties.getUrl() == null) {
|
||||
return this.dataSource;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private DataSource createNewDataSource() {
|
||||
return DataSourceBuilder.create().url(this.properties.getUrl())
|
||||
.username(this.properties.getUser())
|
||||
.password(this.properties.getPassword()).build();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -171,8 +173,8 @@ public class LiquibaseAutoConfiguration {
|
||||
}
|
||||
|
||||
private void closeDataSource() {
|
||||
Method closeMethod = ReflectionUtils.findMethod(getDataSource().getClass(),
|
||||
"close");
|
||||
Class<?> dataSourceClass = getDataSource().getClass();
|
||||
Method closeMethod = ReflectionUtils.findMethod(dataSourceClass, "close");
|
||||
if (closeMethod != null) {
|
||||
ReflectionUtils.invokeMethod(closeMethod, getDataSource());
|
||||
}
|
||||
|
||||
@@ -73,8 +73,8 @@ public class Deprecation implements Serializable {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Deprecation{" + "level='" + this.level + '\'' + ", reason='"
|
||||
+ this.reason + '\'' + ", replacement='" + this.replacement + '\'' + '}';
|
||||
return "Deprecation{" + "level='" + this.level + '\'' + ", reason='" + this.reason
|
||||
+ '\'' + ", replacement='" + this.replacement + '\'' + '}';
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -157,8 +157,7 @@ public class JsonReaderTests extends AbstractConfigurationMetadataTests {
|
||||
.isEqualTo("Server namespace has moved to spring.server");
|
||||
assertThat(item.getDeprecation().getReplacement())
|
||||
.isEqualTo("server.spring.port");
|
||||
assertThat(item.getDeprecation().getLevel())
|
||||
.isEqualTo(Deprecation.Level.WARNING);
|
||||
assertThat(item.getDeprecation().getLevel()).isEqualTo(Deprecation.Level.WARNING);
|
||||
|
||||
ConfigurationMetadataItem item2 = items.get(1);
|
||||
assertProperty(item2, "server.cluster-name", "server.cluster-name", String.class,
|
||||
@@ -166,8 +165,7 @@ public class JsonReaderTests extends AbstractConfigurationMetadataTests {
|
||||
assertThat(item2.isDeprecated()).isTrue();
|
||||
assertThat(item2.getDeprecation().getReason()).isNull();
|
||||
assertThat(item2.getDeprecation().getReplacement()).isNull();
|
||||
assertThat(item.getDeprecation().getLevel())
|
||||
.isEqualTo(Deprecation.Level.WARNING);
|
||||
assertThat(item.getDeprecation().getLevel()).isEqualTo(Deprecation.Level.WARNING);
|
||||
|
||||
ConfigurationMetadataItem item3 = items.get(2);
|
||||
assertProperty(item3, "spring.server.name", "spring.server.name", String.class,
|
||||
@@ -176,16 +174,17 @@ public class JsonReaderTests extends AbstractConfigurationMetadataTests {
|
||||
assertThat(item3.getDeprecation()).isEqualTo(null);
|
||||
|
||||
ConfigurationMetadataItem item4 = items.get(3);
|
||||
assertProperty(item4, "spring.server-name", "spring.server-name", String.class, null);
|
||||
assertProperty(item4, "spring.server-name", "spring.server-name", String.class,
|
||||
null);
|
||||
assertThat(item4.isDeprecated()).isTrue();
|
||||
assertThat(item4.getDeprecation().getReason()).isNull();
|
||||
assertThat(item4.getDeprecation().getReplacement())
|
||||
.isEqualTo("spring.server.name");
|
||||
assertThat(item4.getDeprecation().getLevel())
|
||||
.isEqualTo(Deprecation.Level.ERROR);
|
||||
assertThat(item4.getDeprecation().getLevel()).isEqualTo(Deprecation.Level.ERROR);
|
||||
|
||||
ConfigurationMetadataItem item5 = items.get(4);
|
||||
assertProperty(item5, "spring.server-name2", "spring.server-name2", String.class, null);
|
||||
assertProperty(item5, "spring.server-name2", "spring.server-name2", String.class,
|
||||
null);
|
||||
assertThat(item5.isDeprecated()).isTrue();
|
||||
assertThat(item5.getDeprecation().getReason()).isNull();
|
||||
assertThat(item5.getDeprecation().getReplacement())
|
||||
|
||||
Reference in New Issue
Block a user