DataSouceBuilder can fail with a NPE when the driver is null#45976
DataSouceBuilder can fail with a NPE when the driver is null#45976chanbinme wants to merge 1 commit intospring-projects:mainfrom
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 <gksmfcksqls@gmail.com>
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 <gksmfcksqls@gmail.com>
|
Thanks @chanbinme |
|
@snicoll |
This PR fixes a potential
NullPointerExceptioninSimpleDataSourcePropertieswhen mapping the driver class name property.When a
SimpleDriverDataSourceis 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
nullinstead of throwing NPE.