rdblue commented on a change in pull request #1478:
URL: https://github.com/apache/iceberg/pull/1478#discussion_r496310879



##########
File path: 
hive-metastore/src/main/java/org/apache/iceberg/hive/HiveClientPool.java
##########
@@ -41,7 +41,16 @@ public HiveClientPool(int poolSize, Configuration conf) {
   @Override
   protected HiveMetaStoreClient newClient()  {
     try {
-      return new HiveMetaStoreClient(hiveConf);
+      // create the metastore client based on whether we're working with Hive2 
or Hive3 dependencies
+      // we need to do this because there is a breaking API change between 
Hive2 and Hive3
+      if (MetastoreUtil.hive3PresentOnClasspath()) {
+        return (HiveMetaStoreClient) Class
+                .forName(HiveMetaStoreClient.class.getName())
+                .getConstructor(Configuration.class)
+                .newInstance(hiveConf);

Review comment:
       Can you use `DynCtors` instead? I think this can be simpler:
   
   ```java
     private static final DynConstructors.Ctor<HiveMetaStoreClient> CLIENT_CTOR 
= DynConstructors.builder()
         .impl(HiveMetaStoreClient.class, HiveConf.class)
         .impl(HiveMetaStoreClient.class, Configuration.class)
         .build();
   
     protected HiveMetaStoreClient newClient()  {
       try {
         return CLIENT_CTOR.newInstance(hiveConf);
       } catch (...) {
         ...
       }
     }
   ```
   
   This also exposes a bug with the reflection path: `MetaException` is no 
longer thrown in the `try` block. Since that's a checked exception, it will be 
wrapped in a `RuntimeException`. You'll need to replace that block with `catch 
(RuntimeException e) { ... }` and check the cause of the exception for a 
`MetaException`.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to