浏览代码

HUE-9112 [hdfs] Avoid potential log trace failure similarly to Resource

If one of the path truly can't be printed as is, better to sanitize it
so that the exception is properly raised instead of creating a different
failure.
Romain 5 年之前
父节点
当前提交
56b05cc00a
共有 1 个文件被更改,包括 2 次插入3 次删除
  1. 2 3
      desktop/libs/hadoop/src/hadoop/fs/webhdfs.py

+ 2 - 3
desktop/libs/hadoop/src/hadoop/fs/webhdfs.py

@@ -47,8 +47,7 @@ from hadoop.fs.webhdfs_types import WebHdfsStat, WebHdfsContentSummary
 from hadoop.hdfs_site import get_nn_sentry_prefixes, get_umask_mode, get_supergroup, get_webhdfs_ssl
 
 if sys.version_info[0] > 2:
-  from urllib.parse import unquote as urllib_quote
-  from urllib.parse import urlparse
+  from urllib.parse import unquote as urllib_quote, urlparse
 else:
   from urllib import unquote as urllib_quote
   from urlparse import urlparse
@@ -472,7 +471,7 @@ class WebHdfs(Hdfs):
     headers = self._getheaders()
     result = self._root.put(old, params, headers=headers)
     if not result['boolean']:
-      raise IOError(_("Rename failed: %s -> %s") % (smart_str(old), smart_str(new)))
+      raise IOError(_("Rename failed: %s -> %s") % (smart_str(old, errors='replace'), smart_str(new, errors='replace')))
 
   def rename_star(self, old_dir, new_dir):
     """Equivalent to `mv old_dir/* new"""