[CONCPP-29] Conector/C++ returns NULL on invalid URI instead of throwing an exception Created: 2020-06-30 Updated: 2020-08-11 Resolved: 2020-08-11 |
|
| Status: | Closed |
| Project: | MariaDB Connector/C++ |
| Component/s: | General |
| Affects Version/s: | 0.9.2 |
| Fix Version/s: | 0.9.3 |
| Type: | Bug | Priority: | Minor |
| Reporter: | Anders Karlsson | Assignee: | Lawrin Novitsky |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
Linux CentOS 7.7 |
||
| Description |
|
The following code cause a core dump. This is due to the URI being badly formatted. The expected behavior would be to throw an exception.
The error is in MariaDbDriver.cpp at:
|
| Comments |
| Comment by Lawrin Novitsky [ 2020-07-01 ] |
|
karlsson C/J also returns null, and does not throw. Thus I suspect that is in conformance with jdbc specs. |
| Comment by Anders Karlsson [ 2020-07-02 ] |
|
I had a look, and yes, the connect method of a JDBC Driver returns null if the URL is invalid according to the JDBC Standard. User connecting to a JDBC driver would connect through the DriverManager.getConnection() method though, and this will throw an error instead of returning NULL if the URL is wrong. As there is no DriverManager in C++, a user will have to use the connect method instead, which is reasonable, but it would be better if it them followed the semantics of DriverManager.getConnection(). |
| Comment by Lawrin Novitsky [ 2020-08-11 ] |
|
Introduced DriverManager class with getConnection functionality only. Unlike connecting via Driver class, DriverManager::getConnection methods throw an exception in case connection could not be established for whatever reason. i.e. also if the format of url is incorrect and could not be parsed. DriverManager only permits jdbc:mariadb:// type of url. Well, it's driver manager after all, and needs to know which driver to invoke. Changed unit tests to connect via DriverManager |