HDFS-11689. New exception thrown by DFSClient%isHDFSEncryptionEnabled broke hacky hive code. Contributed by Yongjun Zhang.

(cherry picked from commit 5078df7be3)
This commit is contained in:
Yongjun Zhang 2017-04-21 13:36:31 -07:00
parent 3b7bb7b94b
commit 31d7d47070
2 changed files with 17 additions and 9 deletions

View File

@ -3067,10 +3067,24 @@ public class DFSClient implements java.io.Closeable, RemotePeerFactory,
/** /**
* Probe for encryption enabled on this filesystem. * 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 * @return true if encryption is enabled
*/ */
public boolean isHDFSEncryptionEnabled() throws IOException{ @Deprecated
return getKeyProviderUri() != null; 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;
} }
/** /**

View File

@ -2520,15 +2520,9 @@ public class DistributedFileSystem extends FileSystem {
*/ */
@Override @Override
public Path getTrashRoot(Path path) { public Path getTrashRoot(Path path) {
try {
if ((path == null) || !dfs.isHDFSEncryptionEnabled()) { if ((path == null) || !dfs.isHDFSEncryptionEnabled()) {
return super.getTrashRoot(path); return super.getTrashRoot(path);
} }
} catch (IOException ioe) {
DFSClient.LOG.warn("Exception while checking whether encryption zone is "
+ "supported", ioe);
return super.getTrashRoot(path);
}
String parentSrc = path.isRoot()? String parentSrc = path.isRoot()?
path.toUri().getPath():path.getParent().toUri().getPath(); path.toUri().getPath():path.getParent().toUri().getPath();