mirror of
https://github.com/spring-projects/spring-boot.git
synced 2026-09-17 12:09:16 +00:00
Polish "Avoid NPE in SimpleDataSourceProperties when driver is null"
See gh-45976
This commit is contained in:
+1
-1
@@ -709,7 +709,7 @@ public final class DataSourceBuilder<T extends DataSource> {
|
||||
SimpleDataSourceProperties() {
|
||||
add(DataSourceProperty.URL, SimpleDriverDataSource::getUrl, SimpleDriverDataSource::setUrl);
|
||||
add(DataSourceProperty.DRIVER_CLASS_NAME, Class.class,
|
||||
(dataSource) -> dataSource.getDriver() == null ? null : dataSource.getDriver().getClass(),
|
||||
(dataSource) -> (dataSource.getDriver() != null) ? dataSource.getDriver().getClass() : null,
|
||||
SimpleDriverDataSource::setDriverClass);
|
||||
add(DataSourceProperty.USERNAME, SimpleDriverDataSource::getUsername, SimpleDriverDataSource::setUsername);
|
||||
add(DataSourceProperty.PASSWORD, SimpleDriverDataSource::getPassword, SimpleDriverDataSource::setPassword);
|
||||
|
||||
+1
-1
@@ -358,7 +358,7 @@ class DataSourceBuilderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void buildWhenDerivedFromSimpleDriverDataSourceWithDriverNotSetSucceeds() throws Exception {
|
||||
void buildWhenDerivedFromSimpleDriverDataSourceAndDriverNotSetBuilds() {
|
||||
SimpleDriverDataSource dataSource = new SimpleDriverDataSource();
|
||||
dataSource.setUsername("test");
|
||||
dataSource.setPassword("secret");
|
||||
|
||||
Reference in New Issue
Block a user