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 ef499505ec..7773891cb3 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 @@ -2944,10 +2944,24 @@ public void setKeyProvider(KeyProvider provider) { /** * 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 e1c2105aff..cfe7240a4b 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 @@ -2570,13 +2570,7 @@ public Void next(final FileSystem fs, final Path p) throws IOException { */ @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); }