hive-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ana Jalba (Jira)" <j...@apache.org>
Subject [jira] [Commented] (HIVE-21508) ClassCastException when initializing HiveMetaStoreClient on JDK10 or newer
Date Wed, 04 Sep 2019 16:25:00 GMT

    [ https://issues.apache.org/jira/browse/HIVE-21508?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16922643#comment-16922643
] 

Ana Jalba commented on HIVE-21508:
----------------------------------

The only way I could test this change was by adding the same test for different JDK versioned
projects:
{code:java}
@Test
public void test() throws URISyntaxException {
  URI[] metastoreUris = { new URI("thrift://localhost1:9083"),
                          new URI("thrift://localhost1:9083"),
                          new URI("thrift://localhost2:9083") };
  List<URI> uriList = Arrays.asList(metastoreUris);
  Collections.shuffle(uriList);
  metastoreUris = uriList.toArray(new URI[uriList.size()]);
  System.out.println(metastoreUris[0]);
}
{code}
I tested it with Java 7, 8 and 11 and they all passed.


> ClassCastException when initializing HiveMetaStoreClient on JDK10 or newer
> --------------------------------------------------------------------------
>
>                 Key: HIVE-21508
>                 URL: https://issues.apache.org/jira/browse/HIVE-21508
>             Project: Hive
>          Issue Type: Bug
>          Components: Clients
>    Affects Versions: 3.2.0, 2.3.4
>            Reporter: Adar Dembo
>            Assignee: Ana Jalba
>            Priority: Major
>             Fix For: 2.4.0, 3.2.0, 2.3.7
>
>         Attachments: HIVE-21508.branch-2.3.patch, HIVE-21508.branch-2.patch, HIVE-21508.branch-3.1.patch,
HIVE-21508.branch-3.patch, HIVE-21508.patch
>
>
> There's this block of code in {{HiveMetaStoreClient:resolveUris}} (called from the constructor)
on master:
> {noformat}
>   private URI metastoreUris[];
>   ...
>       if (MetastoreConf.getVar(conf, ConfVars.THRIFT_URI_SELECTION).equalsIgnoreCase("RANDOM"))
{
>         List uriList = Arrays.asList(metastoreUris);
>         Collections.shuffle(uriList);
>         metastoreUris = (URI[]) uriList.toArray();
>       }
> {noformat}
> The cast to {{URI[]}} throws a {{ClassCastException}} beginning with JDK 10, possibly
with JDK 9 as well. Note that {{THRIFT_URI_SELECTION}} defaults to {{RANDOM}} so this should
affect anyone who creates a {{HiveMetaStoreClient}}. On master this can be overridden with
{{SEQUENTIAL}} to avoid the broken case; I'm working against 2.3.4 where there's no such workaround.
> [Here's|https://stackoverflow.com/questions/51372788/array-cast-java-8-vs-java-9] a StackOverflow
post that explains the issue in more detail. Interestingly, the author described the issue
in the context of the HMS; not sure why there was no follow up with a Hive bug report.



--
This message was sent by Atlassian Jira
(v8.3.2#803003)

Mime
View raw message