Repository: hive Updated Branches: refs/heads/branch-1 5b0825f16 -> 0596951d2
HIVE-13090 : Hive metastore crashes on NPE with ZooKeeperTokenStore (Piotr WikieÅ, Thejas Nair, reviewed by Ashutosh Chauhan) Project: http://git-wip-us.apache.org/repos/asf/hive/repo Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/0596951d Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/0596951d Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/0596951d Branch: refs/heads/branch-1 Commit: 0596951d2295cf42c63e88a0f805a3db0188b01b Parents: 5b0825f Author: Thejas Nair <the...@hortonworks.com> Authored: Mon Feb 22 09:06:56 2016 -0800 Committer: Thejas Nair <the...@hortonworks.com> Committed: Mon Feb 22 09:07:38 2016 -0800 ---------------------------------------------------------------------- .../org/apache/hadoop/hive/thrift/TestZooKeeperTokenStore.java | 1 + .../hive/thrift/TokenStoreDelegationTokenSecretManager.java | 1 - .../java/org/apache/hadoop/hive/thrift/ZooKeeperTokenStore.java | 4 ++++ 3 files changed, 5 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hive/blob/0596951d/itests/hive-unit/src/test/java/org/apache/hadoop/hive/thrift/TestZooKeeperTokenStore.java ---------------------------------------------------------------------- diff --git a/itests/hive-unit/src/test/java/org/apache/hadoop/hive/thrift/TestZooKeeperTokenStore.java b/itests/hive-unit/src/test/java/org/apache/hadoop/hive/thrift/TestZooKeeperTokenStore.java index 9848cc1..65a10e3 100644 --- a/itests/hive-unit/src/test/java/org/apache/hadoop/hive/thrift/TestZooKeeperTokenStore.java +++ b/itests/hive-unit/src/test/java/org/apache/hadoop/hive/thrift/TestZooKeeperTokenStore.java @@ -122,6 +122,7 @@ public class TestZooKeeperTokenStore extends TestCase { assertTrue(ts.removeToken(tokenId)); assertEquals(0, ts.getAllDelegationTokenIdentifiers().size()); + assertNull(ts.getToken(tokenId)); } public void testAclNoAuth() throws Exception { http://git-wip-us.apache.org/repos/asf/hive/blob/0596951d/shims/common/src/main/java/org/apache/hadoop/hive/thrift/TokenStoreDelegationTokenSecretManager.java ---------------------------------------------------------------------- diff --git a/shims/common/src/main/java/org/apache/hadoop/hive/thrift/TokenStoreDelegationTokenSecretManager.java b/shims/common/src/main/java/org/apache/hadoop/hive/thrift/TokenStoreDelegationTokenSecretManager.java index 8146d51..87b418e 100644 --- a/shims/common/src/main/java/org/apache/hadoop/hive/thrift/TokenStoreDelegationTokenSecretManager.java +++ b/shims/common/src/main/java/org/apache/hadoop/hive/thrift/TokenStoreDelegationTokenSecretManager.java @@ -330,7 +330,6 @@ public class TokenStoreDelegationTokenSecretManager extends DelegationTokenSecre } catch (Throwable t) { LOGGER.error("ExpiredTokenRemover thread received unexpected exception. " + t, t); - Runtime.getRuntime().exit(-1); } } } http://git-wip-us.apache.org/repos/asf/hive/blob/0596951d/shims/common/src/main/java/org/apache/hadoop/hive/thrift/ZooKeeperTokenStore.java ---------------------------------------------------------------------- diff --git a/shims/common/src/main/java/org/apache/hadoop/hive/thrift/ZooKeeperTokenStore.java b/shims/common/src/main/java/org/apache/hadoop/hive/thrift/ZooKeeperTokenStore.java index 745e467..528e55d 100644 --- a/shims/common/src/main/java/org/apache/hadoop/hive/thrift/ZooKeeperTokenStore.java +++ b/shims/common/src/main/java/org/apache/hadoop/hive/thrift/ZooKeeperTokenStore.java @@ -396,6 +396,10 @@ public class ZooKeeperTokenStore implements DelegationTokenStore { @Override public DelegationTokenInformation getToken(DelegationTokenIdentifier tokenIdentifier) { byte[] tokenBytes = zkGetData(getTokenPath(tokenIdentifier)); + if(tokenBytes == null) { + // The token is already removed. + return null; + } try { return HiveDelegationTokenSupport.decodeDelegationTokenInformation(tokenBytes); } catch (Exception ex) {