sentry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ak...@apache.org
Subject sentry git commit: SENTRY-1357: SentryMetastorePostEventListenerBase.onAlterTable should check for null dereference (Ke Jia via Dapeng Sun)
Date Sat, 11 Mar 2017 02:06:45 GMT
Repository: sentry
Updated Branches:
  refs/heads/sentry-ha-redesign 1e031de81 -> 63352d834


SENTRY-1357: SentryMetastorePostEventListenerBase.onAlterTable should check for null dereference
(Ke Jia via Dapeng Sun)


Project: http://git-wip-us.apache.org/repos/asf/sentry/repo
Commit: http://git-wip-us.apache.org/repos/asf/sentry/commit/63352d83
Tree: http://git-wip-us.apache.org/repos/asf/sentry/tree/63352d83
Diff: http://git-wip-us.apache.org/repos/asf/sentry/diff/63352d83

Branch: refs/heads/sentry-ha-redesign
Commit: 63352d834387588547c7e0a5f284533c2e54aa99
Parents: 1e031de
Author: Alexander Kolbasov <akolb@cloudera.com>
Authored: Fri Mar 10 18:06:40 2017 -0800
Committer: Alexander Kolbasov <akolb@cloudera.com>
Committed: Fri Mar 10 18:06:40 2017 -0800

----------------------------------------------------------------------
 .../SentryMetastorePostEventListenerBase.java   | 23 ++++++++++++++------
 1 file changed, 16 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/sentry/blob/63352d83/sentry-binding/sentry-binding-hive-common/src/main/java/org/apache/sentry/binding/metastore/SentryMetastorePostEventListenerBase.java
----------------------------------------------------------------------
diff --git a/sentry-binding/sentry-binding-hive-common/src/main/java/org/apache/sentry/binding/metastore/SentryMetastorePostEventListenerBase.java
b/sentry-binding/sentry-binding-hive-common/src/main/java/org/apache/sentry/binding/metastore/SentryMetastorePostEventListenerBase.java
index 46363a5..262db11 100644
--- a/sentry-binding/sentry-binding-hive-common/src/main/java/org/apache/sentry/binding/metastore/SentryMetastorePostEventListenerBase.java
+++ b/sentry-binding/sentry-binding-hive-common/src/main/java/org/apache/sentry/binding/metastore/SentryMetastorePostEventListenerBase.java
@@ -217,13 +217,22 @@ public class SentryMetastorePostEventListenerBase extends MetaStoreEventListener
         " since the operation failed. \n");
       return;
     }
-
-    renameSentryTablePrivilege(tableEvent.getOldTable().getDbName(),
-        tableEvent.getOldTable().getTableName(),
-        tableEvent.getOldTable().getSd().getLocation(),
-        tableEvent.getNewTable().getDbName(),
-        tableEvent.getNewTable().getTableName(),
-        tableEvent.getNewTable().getSd().getLocation());
+    String oldLoc = null, newLoc = null;
+    org.apache.hadoop.hive.metastore.api.Table oldTal = tableEvent.getOldTable();
+    org.apache.hadoop.hive.metastore.api.Table newTal = tableEvent.getNewTable();
+    if (oldTal != null && oldTal.getSd() != null) {
+      oldLoc = oldTal.getSd().getLocation();
+    }
+    if (newTal != null && newTal.getSd() != null) {
+      newLoc = newTal.getSd().getLocation();
+    }
+    if (oldLoc != null && newLoc != null && !oldLoc.equals(newLoc)) {
+      String oldDbName = tableEvent.getOldTable().getDbName();
+      String oldTbName = tableEvent.getOldTable().getTableName();
+      String newTbName = tableEvent.getNewTable().getTableName();
+      String newDbName = tableEvent.getNewTable().getDbName();
+      renameSentryTablePrivilege(oldDbName, oldTbName, oldLoc, newDbName, newTbName, newLoc);
+    }
   }
 
   @Override


Mime
View raw message