From c88e5e1836103d7abc6cdb40588bce8d245c897c Mon Sep 17 00:00:00 2001 From: Yongjun Zhang Date: Fri, 21 Apr 2017 13:36:31 -0700 Subject: [PATCH] HDFS-11689. New exception thrown by DFSClient%isHDFSEncryptionEnabled broke hacky hive code. Contributed by Yongjun Zhang. (cherry picked from commit 5078df7be317e635615c05c5da3285798993ff1f) --- .../java/org/apache/hadoop/hdfs/DFSClient.java | 18 ++++++++++++++++-- .../hadoop/hdfs/DistributedFileSystem.java | 8 +------- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DFSClient.java b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DFSClient.java index a8a63dd9d51..01b9a6af3e9 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DFSClient.java +++ b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DFSClient.java @@ -3060,10 +3060,24 @@ public class DFSClient implements java.io.Closeable, RemotePeerFactory, /** * Probe for encryption enabled on this filesystem. + * Note (see HDFS-11689): + * Not to throw exception in this method since it would break hive. + * Hive accesses this method and assumes no exception would be thrown. + * Hive should not access DFSClient since it is InterfaceAudience.Private. + * Deprecated annotation is added to trigger build warning at hive side. + * Request has been made to Hive to remove access to DFSClient. * @return true if encryption is enabled */ - public boolean isHDFSEncryptionEnabled() throws IOException{ - return getKeyProviderUri() != null; + @Deprecated + public boolean isHDFSEncryptionEnabled() { + boolean result = false; + try { + result = (getKeyProviderUri() != null); + } catch (IOException ioe) { + DFSClient.LOG.warn("Exception while checking whether encryption zone " + + "is supported, assumes it is not supported", ioe); + } + return result; } /** diff --git a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DistributedFileSystem.java b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DistributedFileSystem.java index a99e9ea69cf..3305c89142c 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DistributedFileSystem.java +++ b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DistributedFileSystem.java @@ -2476,13 +2476,7 @@ public class DistributedFileSystem extends FileSystem { */ @Override public Path getTrashRoot(Path path) { - try { - if ((path == null) || !dfs.isHDFSEncryptionEnabled()) { - return super.getTrashRoot(path); - } - } catch (IOException ioe) { - DFSClient.LOG.warn("Exception while checking whether encryption zone is " - + "supported", ioe); + if ((path == null) || !dfs.isHDFSEncryptionEnabled()) { return super.getTrashRoot(path); }