Uploaded image for project: 'MariaDB Connector/J'
  1. MariaDB Connector/J
  2. CONJ-167

Driver is throwing IllegalArgumentException instead of returning null

Details

    • Bug
    • Status: Closed (View Workflow)
    • Critical
    • Resolution: Fixed
    • 1.2.0
    • 1.2.2
    • Other
    • None
    • JDK 8
    • 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
      at org.mariadb.jdbc.JDBCUrl.parse(JDBCUrl.java:144)
      at org.mariadb.jdbc.Driver.connect(Driver.java:95)
      at java.sql.DriverManager.getConnection(DriverManager.java:664)
      at java.sql.DriverManager.getConnection(DriverManager.java:208)

      Attachments

        Activity

          harel.e Harel E. created issue -
          diego dupin Diego Dupin made changes -
          Field Original Value New Value
          Assignee Georg Richter [ georg ] diego dupin [ diego dupin ]
          diego dupin Diego Dupin added a comment -

          Exactly.
          The "IllegalArgumentException" must be thrown only if URL is valid for mariadb.

          diego dupin Diego Dupin added a comment - Exactly. The "IllegalArgumentException" must be thrown only if URL is valid for mariadb.
          diego dupin Diego Dupin made changes -
          Status Open [ 1 ] In Progress [ 3 ]
          diego dupin Diego Dupin made changes -
          Fix Version/s 1.2.1 [ 19602 ]
          Resolution Fixed [ 1 ]
          Status In Progress [ 3 ] Closed [ 6 ]
          harel.e Harel E. added a comment -

          The Driver should return null if the URL is invalid.
          The Driver should throw SQLException if the URL is valid, but cannot connect to the Database.

          Otherwise, it should return the Connection object.

          It should not throw any RuntimeException

          harel.e Harel E. added a comment - The Driver should return null if the URL is invalid. The Driver should throw SQLException if the URL is valid, but cannot connect to the Database. Otherwise, it should return the Connection object. It should not throw any RuntimeException
          harel.e Harel E. added a comment -

          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

          harel.e Harel E. added a comment - 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
          diego dupin Diego Dupin added a comment -

          Thanks about your point, clearly to be changed.

          Add commit https://github.com/MariaDB/mariadb-connector-j/commit/4419ac044cfa609e01d491218ef6751b2bb8537f
          concerning replacement of RuntimeException by SQLException.

          diego dupin Diego Dupin added a comment - Thanks about your point, clearly to be changed. Add commit https://github.com/MariaDB/mariadb-connector-j/commit/4419ac044cfa609e01d491218ef6751b2bb8537f concerning replacement of RuntimeException by SQLException.
          harel.e Harel E. added a comment -

          Thanks for the quick fix

          harel.e Harel E. added a comment - Thanks for the quick fix
          diego dupin Diego Dupin made changes -
          Sprint Sprint 1 [ 11 ]
          diego dupin Diego Dupin made changes -
          Fix Version/s 1.2.2 [ 19900 ]
          Fix Version/s 1.3.0 [ 19602 ]
          serg Sergei Golubchik made changes -
          Workflow MariaDB v3 [ 70712 ] MariaDB v4 [ 134782 ]

          People

            diego dupin Diego Dupin
            harel.e Harel E.
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.