[CONJ-167] Driver is throwing IllegalArgumentException instead of returning null Created: 2015-07-20 Updated: 2015-09-02 Resolved: 2015-07-21 |
|
| Status: | Closed |
| Project: | MariaDB Connector/J |
| Component/s: | Other |
| Affects Version/s: | 1.2.0 |
| Fix Version/s: | 1.2.2 |
| Type: | Bug | Priority: | Critical |
| Reporter: | Harel E. | Assignee: | Diego Dupin |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Environment: |
JDK 8 |
||
| Sprint: | Sprint connector/j 1.3.0 |
| Description |
|
From* java.sql.Driver.connect* javadoc The driver should return "null" if it realizes it is the wrong kind of driver to connect to the given URL The problem I ran into is that when the application is loaded with other other jdbc drivers (e.g. H2), mariadb driver is throwing an exception instead of returning null. This exception prevents DriveManager to continue checking other drivers for URL compatibility. Caused by: java.lang.IllegalArgumentException: Invalid connection URL url jdbc:h2:mem:RZM;DB_CLOSE_DELAY=-1 |
| Comments |
| Comment by Diego Dupin [ 2015-07-21 ] |
|
Exactly. |
| Comment by Harel E. [ 2015-07-21 ] |
|
The Driver should return null if the URL is invalid. Otherwise, it should return the Connection object. It should not throw any RuntimeException |
| Comment by Harel E. [ 2015-07-21 ] |
|
IMHO the right thing to do, if you encounter an invalid URL with the correct prefix is to throw SQLException (or subclass of it) and not IllegalArgumentException |
| Comment by Diego Dupin [ 2015-07-21 ] |
|
Thanks about your point, clearly to be changed. Add commit https://github.com/MariaDB/mariadb-connector-j/commit/4419ac044cfa609e01d491218ef6751b2bb8537f |
| Comment by Harel E. [ 2015-07-21 ] |
|
Thanks for the quick fix |