Uploaded image for project: 'Hive'
  1. Hive
  2. HIVE-6363

IllegalArgumentException is thrown instead of SQLException

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Critical
    • Resolution: Duplicate
    • 0.10.0, 0.11.0, 0.12.0
    • None
    • JDBC
    • Hide
      The HIVE JDBC driver now throws an SQLException when given an invalid URL. Previously, it through an IllegalArgumentException, which was not compatible with java.sql.DriverManager in OpenJDK 1.7. As a result of the change, the HIVE JDBC driver can now be used when other JDBC drivers are present in the classpath.
      Show
      The HIVE JDBC driver now throws an SQLException when given an invalid URL. Previously, it through an IllegalArgumentException, which was not compatible with java.sql.DriverManager in OpenJDK 1.7. As a result of the change, the HIVE JDBC driver can now be used when other JDBC drivers are present in the classpath.

    Description

      parseURL in the following code is throwing IllegalArgumentException
      http://svn.apache.org/viewvc/hive/trunk/jdbc/src/java/org/apache/hive/jdbc/Utils.java?view=markup

      This is going to break other JDBC based connectors because java.sql.DriverManager doesn’t catch IllegalArgumentException while probing for correct Driver for a given URL.

      A simple test case can have class.forName(org.apache.hive.jdbc.HiveDriver) (Loading hiveserver2 JDBC driver) followed by class.forName(org.apache.hadoop.hive.jdbc.HiveDriver)(Loading hiveserver JDBC driver).

      In this case hiveserver connection will fail with BAD URL format for hiveserver. If you reverse the driver loading to hiveserver followed by hiveserver2, both the connections will be successful.

      Following code in java.sql.DriverManager is causing the issue
      [[
      // Worker method called by the public getConnection() methods.
      private static Connection getConnection(
      // Walk through the loaded registeredDrivers attempting to make a connection.
      // Remember the first exception that gets raised so we can reraise it.

      for(DriverInfo aDriver : registeredDrivers) {
      // If the caller does not have permission to load the driver then
      // skip it.
      if(isDriverAllowed(aDriver.driver, callerCL)) {
      try {
      Connection con = aDriver.driver.connect(url, info);
      if (con != null) {
      // Success!
      println("getConnection returning " + aDriver.driver.getClass().getName());
      return (con);
      }
      } catch (SQLException ex) {
      if (reason == null)

      { reason = ex; } } }

      else

      { println(" skipping: " + aDriver.getClass().getName()); } }

      }
      ]]

      Marking it as critical because this is going to restrict consuming JDBC driver in production environment where many drivers are loaded on requirement rather than statically loading all drivers.

      Attachments

        1. HIVE-6363.patch.1.txt
          2 kB
          Brian Muray
        2. HIVE-6363.patch.2.txt
          3 kB
          Brian Muray

        Issue Links

          Activity

            People

              Unassigned Unassigned
              chandugunturi chandra sekhar gunturi
              Votes:
              1 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - 24h
                  24h
                  Remaining:
                  Remaining Estimate - 24h
                  24h
                  Logged:
                  Time Spent - Not Specified
                  Not Specified