-
Notifications
You must be signed in to change notification settings - Fork 41.3k
DataSouceBuilder can fail with a NPE when the driver is null #45976
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
DataSouceBuilder can fail with a NPE when the driver is null #45976
Conversation
Thanks for the PR, @chanbinme. Could you please add a test that fails due to an NPE without the proposed change? If I've understood the problem correctly, I think that will require deriving a |
05fe8ea
to
e52480a
Compare
- Prevent NullPointerException in SimpleDataSourceProperties by adding null check before calling getDriver().getClass(). - Fixes potential crash when driver is not explicitly configured. - Add null checks in convertToString method to handle null Class values - Add test case to verify NPE-free operation when deriving DataSource Signed-off-by: chanbinme <[email protected]>
e52480a
to
f92fc35
Compare
Thank you for the feedback! You're absolutely right about adding a test to demonstrate the NPE issue. I'll add a test case following the existing naming convention, something like: While writing the test, I discovered an additional NPE issue in the |
See gh-45976 Signed-off-by: chanbinme <[email protected]>
Thanks @chanbinme |
@snicoll |
This PR fixes a potential
NullPointerException
inSimpleDataSourceProperties
when mapping the driver class name property.When a
SimpleDriverDataSource
is created without explicitly setting a driver, callingdataSource.getDriver().getClass()
throws NPE becausegetDriver()
returnsnull
.Added null check to safely handle the case when no driver is configured, returning
null
instead of throwing NPE.