Repository: hive Updated Branches: refs/heads/master 63ffa3c72 -> a9de1cdbb
HIVE-16047: Shouldn't try to get KeyProvider unless encryption is enabled (Rui reviewed by Xuefu and Ferdinand) Project: http://git-wip-us.apache.org/repos/asf/hive/repo Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/a9de1cdb Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/a9de1cdb Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/a9de1cdb Branch: refs/heads/master Commit: a9de1cdbb9ffeef43dbee3db1712845f015ac108 Parents: 63ffa3c Author: Rui Li <[email protected]> Authored: Wed Mar 1 11:16:27 2017 +0800 Committer: Rui Li <[email protected]> Committed: Wed Mar 1 11:16:27 2017 +0800 ---------------------------------------------------------------------- .../org/apache/hadoop/hive/shims/Hadoop23Shims.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hive/blob/a9de1cdb/shims/0.23/src/main/java/org/apache/hadoop/hive/shims/Hadoop23Shims.java ---------------------------------------------------------------------- diff --git a/shims/0.23/src/main/java/org/apache/hadoop/hive/shims/Hadoop23Shims.java b/shims/0.23/src/main/java/org/apache/hadoop/hive/shims/Hadoop23Shims.java index 0483e91..e6af00d 100644 --- a/shims/0.23/src/main/java/org/apache/hadoop/hive/shims/Hadoop23Shims.java +++ b/shims/0.23/src/main/java/org/apache/hadoop/hive/shims/Hadoop23Shims.java @@ -57,6 +57,7 @@ import org.apache.hadoop.fs.TrashPolicy; import org.apache.hadoop.fs.permission.FsAction; import org.apache.hadoop.fs.permission.FsPermission; import org.apache.hadoop.hdfs.DFSClient; +import org.apache.hadoop.hdfs.DFSConfigKeys; import org.apache.hadoop.hdfs.DistributedFileSystem; import org.apache.hadoop.hdfs.MiniDFSCluster; import org.apache.hadoop.hdfs.MiniDFSNNTopology; @@ -1148,10 +1149,22 @@ public class Hadoop23Shims extends HadoopShimsSecure { DistributedFileSystem dfs = (DistributedFileSystem)FileSystem.get(uri, conf); this.conf = conf; - this.keyProvider = dfs.getClient().getKeyProvider(); + this.keyProvider = isEncryptionEnabled(dfs.getClient(), dfs.getConf()) ? + dfs.getClient().getKeyProvider() : null; this.hdfsAdmin = new HdfsAdmin(uri, conf); } + private boolean isEncryptionEnabled(DFSClient client, Configuration conf) { + try { + DFSClient.class.getMethod("isHDFSEncryptionEnabled"); + } catch (NoSuchMethodException e) { + // the method is available since Hadoop-2.7.1 + // if we run with an older Hadoop, check this ourselves + return !conf.getTrimmed(DFSConfigKeys.DFS_ENCRYPTION_KEY_PROVIDER_URI, "").isEmpty(); + } + return client.isHDFSEncryptionEnabled(); + } + @Override public boolean isPathEncrypted(Path path) throws IOException { Path fullPath;
