-
Notifications
You must be signed in to change notification settings - Fork 40.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Databases that support embedded and non-embedded modes are always detected as embedded #23693
Changes from 5 commits
fae930c
0c1ea51
46ae53f
874f67d
ec33a52
2a2a166
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -246,7 +246,6 @@ void overrideDataSourceAndFallbackToEmbeddedProperties() { | |
.run(assertLiquibase((liquibase) -> { | ||
DataSource dataSource = liquibase.getDataSource(); | ||
assertThat(((HikariDataSource) dataSource).isClosed()).isTrue(); | ||
assertThat(((HikariDataSource) dataSource).getUsername()).isEqualTo("sa"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why was this removed? It's configuring an embedded database. |
||
assertThat(((HikariDataSource) dataSource).getPassword()).isEqualTo(""); | ||
})); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -101,7 +101,7 @@ private void process(BeanDefinitionRegistry registry, ConfigurableListableBeanFa | |
|
||
private BeanDefinition createEmbeddedBeanDefinition(boolean primary) { | ||
BeanDefinition beanDefinition = new RootBeanDefinition(EmbeddedDataSourceFactoryBean.class); | ||
beanDefinition.setPrimary(primary); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That doesn't look right and seems unrelated. Please revert this. |
||
beanDefinition.setPrimary(true); | ||
return beanDefinition; | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,7 @@ | |
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType; | ||
import org.springframework.util.Assert; | ||
import org.springframework.util.ClassUtils; | ||
import org.springframework.util.StringUtils; | ||
|
||
/** | ||
* Connection details for {@link EmbeddedDatabaseType embedded databases}. | ||
|
@@ -122,10 +123,23 @@ public String getUrl(String databaseName) { | |
* @param driverClass the driver class | ||
* @return true if the driver class is one of the embedded types | ||
*/ | ||
@Deprecated | ||
public static boolean isEmbedded(String driverClass) { | ||
return driverClass != null && (matches(HSQL, driverClass) || matches(H2, driverClass) | ||
|| matches(DERBY, driverClass) || matches(HSQLDB, driverClass)); | ||
} | ||
/** | ||
* Convenience method to determine if a given driver class name and url represents an embedded | ||
* database type.The exception is made for the H2 database for embedded types. | ||
* @param driverClass the driver class | ||
* @param url the jdbc url | ||
* @return true if the driver class is one of the embedded types | ||
*/ | ||
public static boolean isEmbedded(String driverClass, String url) | ||
{ | ||
return (driverClass != null && (matches(HSQL, driverClass) || ( matches(H2, driverClass) && !StringUtils.hasText("mem")) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The updated code does not use the The check on the url must be more narrowed, something like |
||
|| matches(DERBY, driverClass) || matches(HSQLDB, driverClass))); | ||
} | ||
|
||
private static boolean matches(EmbeddedDatabaseConnection candidate, String driverClass) { | ||
return driverClass.equals(candidate.driverClass) || driverClass.equals(candidate.alternativeDriverClass); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why was this removed? It's configuring an embedded database.