You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by kg...@apache.org on 2021/11/17 08:58:48 UTC

[hive] branch master updated: HIVE-25692: ExceptionHandler may mask checked exceptions (#2782) (Zoltan Haindrich reviewed by Zhihua Deng and Krisztian Kasa)

This is an automated email from the ASF dual-hosted git repository.

kgyrtkirk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hive.git


The following commit(s) were added to refs/heads/master by this push:
     new 8f2dc79  HIVE-25692: ExceptionHandler may mask checked exceptions (#2782) (Zoltan Haindrich reviewed by Zhihua Deng and Krisztian Kasa)
8f2dc79 is described below

commit 8f2dc79e7f9d6355234fd2694caa33cbb5d6733c
Author: Zoltan Haindrich <ki...@rxd.hu>
AuthorDate: Wed Nov 17 09:58:38 2021 +0100

    HIVE-25692: ExceptionHandler may mask checked exceptions (#2782) (Zoltan Haindrich reviewed by Zhihua Deng and Krisztian Kasa)
---
 .../hadoop/hive/metastore/ExceptionHandler.java    | 33 ++++++++++++++++------
 .../apache/hadoop/hive/metastore/HMSHandler.java   | 10 +++++--
 .../hive/metastore/TestExceptionHandler.java       |  2 --
 3 files changed, 31 insertions(+), 14 deletions(-)

diff --git a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/ExceptionHandler.java b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/ExceptionHandler.java
index 8bffa97..ffac608 100644
--- a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/ExceptionHandler.java
+++ b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/ExceptionHandler.java
@@ -44,8 +44,7 @@ public final class ExceptionHandler {
   /**
    * Throws if the input exception is the instance of the input class
    */
-  public <T extends Exception> ExceptionHandler
-      throwIfInstance(Class<T> t) throws T {
+  public <T extends Exception> ExceptionHandler throwIfInstance(Class<T> t) throws T {
     if (t.isInstance(e)) {
       throw t.cast(e);
     }
@@ -55,13 +54,29 @@ public final class ExceptionHandler {
   /**
    * Throws if the input exception is the instance of the one in the input classes
    */
-  public <T extends Exception> ExceptionHandler
-      throwIfInstance(Class ...te) throws T {
-    if (te != null) {
-      for (Class<T> t : te) {
-        throwIfInstance(t);
-      }
-    }
+  public <T1 extends Exception,
+          T2 extends Exception>
+  ExceptionHandler throwIfInstance(
+      Class<T1> te1,
+      Class<T2> te2) throws T1, T2 {
+    throwIfInstance(te1);
+    throwIfInstance(te2);
+    return this;
+  }
+
+  /**
+   * Throws if the input exception is the instance of the one in the input classes
+   */
+  public <T1 extends Exception,
+          T2 extends Exception,
+          T3 extends Exception>
+  ExceptionHandler throwIfInstance(
+      Class<T1> te1,
+      Class<T2> te2,
+      Class<T3> te3) throws T1, T2, T3 {
+    throwIfInstance(te1);
+    throwIfInstance(te2);
+    throwIfInstance(te3);
     return this;
   }
 
diff --git a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HMSHandler.java b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HMSHandler.java
index c2b166b..a2211a4 100644
--- a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HMSHandler.java
+++ b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HMSHandler.java
@@ -3245,7 +3245,7 @@ public class HMSHandler extends FacebookBase implements IHMSHandler {
   }
 
   private void drop_table_with_environment_context(final String dbname, final String name, final boolean deleteData,
-      final EnvironmentContext envContext, boolean dropPartitions) throws MetaException {
+      final EnvironmentContext envContext, boolean dropPartitions) throws MetaException, NoSuchObjectException {
     String[] parsedDbName = parseDbName(dbname, conf);
     startTableFunction("drop_table", parsedDbName[CAT_NAME], parsedDbName[DB_NAME], name);
 
@@ -5190,8 +5190,12 @@ public class HMSHandler extends FacebookBase implements IHMSHandler {
 
     @Override
     public boolean equals(Object o) {
-      if (this == o) return true;
-      if (o == null || getClass() != o.getClass()) return false;
+      if (this == o) {
+        return true;
+      }
+      if (o == null || getClass() != o.getClass()) {
+        return false;
+      }
       PathAndDepth that = (PathAndDepth) o;
       return depth == that.depth && Objects.equals(path, that.path);
     }
diff --git a/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/TestExceptionHandler.java b/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/TestExceptionHandler.java
index 9e79e40..435c085 100644
--- a/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/TestExceptionHandler.java
+++ b/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/TestExceptionHandler.java
@@ -19,7 +19,6 @@
 package org.apache.hadoop.hive.metastore;
 
 import java.io.IOException;
-
 import org.junit.Test;
 
 import org.apache.hadoop.hive.metastore.api.InvalidOperationException;
@@ -120,5 +119,4 @@ public class TestExceptionHandler {
       assertTrue(e.getMessage().equals(ix.getMessage()));
     }
   }
-
 }