sentry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s..@apache.org
Subject sentry git commit: SENTRY-1094: SentryMetastorePostEventListener.onAlterTable should check for null dereference (Ke Jia via Dapeng Sun)
Date Thu, 14 Jul 2016 03:01:05 GMT
Repository: sentry
Updated Branches:
  refs/heads/master b72221b8d -> 7deefdb1d


SENTRY-1094: SentryMetastorePostEventListener.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/7deefdb1
Tree: http://git-wip-us.apache.org/repos/asf/sentry/tree/7deefdb1
Diff: http://git-wip-us.apache.org/repos/asf/sentry/diff/7deefdb1

Branch: refs/heads/master
Commit: 7deefdb1d96aafe3085d901760b0611672bbdd4d
Parents: b72221b
Author: Sun Dapeng <sdp@apache.org>
Authored: Thu Jul 14 10:56:33 2016 +0800
Committer: Sun Dapeng <sdp@apache.org>
Committed: Thu Jul 14 10:56:33 2016 +0800

----------------------------------------------------------------------
 .../SentryMetastorePostEventListener.java       | 24 +++++++++++++++-----
 1 file changed, 18 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/sentry/blob/7deefdb1/sentry-binding/sentry-binding-hive/src/main/java/org/apache/sentry/binding/metastore/SentryMetastorePostEventListener.java
----------------------------------------------------------------------
diff --git a/sentry-binding/sentry-binding-hive/src/main/java/org/apache/sentry/binding/metastore/SentryMetastorePostEventListener.java
b/sentry-binding/sentry-binding-hive/src/main/java/org/apache/sentry/binding/metastore/SentryMetastorePostEventListener.java
index 9844c33..21bfa64 100644
--- a/sentry-binding/sentry-binding-hive/src/main/java/org/apache/sentry/binding/metastore/SentryMetastorePostEventListener.java
+++ b/sentry-binding/sentry-binding-hive/src/main/java/org/apache/sentry/binding/metastore/SentryMetastorePostEventListener.java
@@ -218,12 +218,24 @@ public class SentryMetastorePostEventListener extends MetaStoreEventListener
{
       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