Polish "Avoid NPE in SimpleDataSourceProperties when driver is null"

See gh-45976
This commit is contained in:
Stéphane Nicoll
2025-06-17 14:53:57 +02:00
parent 1cf0d4e7fe
commit 1f031f5fa6
2 changed files with 2 additions and 2 deletions
@@ -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);
@@ -358,7 +358,7 @@ class DataSourceBuilderTests {
}
@Test
void buildWhenDerivedFromSimpleDriverDataSourceWithDriverNotSetSucceeds() throws Exception {
void buildWhenDerivedFromSimpleDriverDataSourceAndDriverNotSetBuilds() {
SimpleDriverDataSource dataSource = new SimpleDriverDataSource();
dataSource.setUsername("test");
dataSource.setPassword("secret");