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

Class HiveMetaStoreClient fails to instantiate when running on Java 11

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Duplicate
    • 2.3.6, 3.1.2
    • 2.3.7
    • Hive
    • Java Version: "11.0.3" 2019-04-16 LTS

    • Patch

    Description

      HiveMetaStoreClient fails to initialize in JDK with error:
      Unable to instantiate org.apache.hadoop.hive.metastore.HiveMetaStoreClient with cause
      class [Ljava.lang.Object; cannot be cast to class [Ljava.net.URI; ([Ljava.lang.Object; and [Ljava.net.URI; are in module java.base of loader 'bootstrap')

      This is due the way toArray is being invoked. The compiles and runs well on Java 8. But when running in Java 11, the class instantiation fails. This is a snippet of code to reproduce the issue:

      URI metastoreUris[] = new URI[2];
      try {
          metastoreUris[0] = new URI("http://google.com");
      } catch (URISyntaxException e) {
          e.printStackTrace();
      }
      List uriList = Arrays.asList(metastoreUris);
      Collections.shuffle(uriList);
      metastoreUris = (URI[]) uriList.toArray();
      

      This is causing any client using HiveMetaStoreClient fail, because the constructor is unable to initialize. The type erasure is handled differently in Java 8 and Java 11.

      Attachments

        1. HIVE-22190.01.patch
          2 kB
          Francisco Guerrero
        2. HIVE-22190.01.patch
          2 kB
          Francisco Guerrero

        Issue Links

          Activity

            People

              frankgh Francisco Guerrero
              frankgh Francisco Guerrero
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

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