Repository: hive Updated Branches: refs/heads/master b784fbc8b -> b3c2011ed
HIVE-19846: Removed Deprecated Calls From FileUtils-getJarFilesByPath (BELUGA BEHR reviewed by Peter Vary) Project: http://git-wip-us.apache.org/repos/asf/hive/repo Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/b3c2011e Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/b3c2011e Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/b3c2011e Branch: refs/heads/master Commit: b3c2011ede676a714b633c7a84b31e4d2ac07d8e Parents: b784fbc Author: BELUGA BEHR <[email protected]> Authored: Thu Nov 29 12:23:46 2018 +0100 Committer: Peter Vary <[email protected]> Committed: Thu Nov 29 12:23:46 2018 +0100 ---------------------------------------------------------------------- .../apache/hadoop/hive/common/FileUtils.java | 24 +++++++++----------- 1 file changed, 11 insertions(+), 13 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hive/blob/b3c2011e/common/src/java/org/apache/hadoop/hive/common/FileUtils.java ---------------------------------------------------------------------- diff --git a/common/src/java/org/apache/hadoop/hive/common/FileUtils.java b/common/src/java/org/apache/hadoop/hive/common/FileUtils.java index cd7a7e6..56748fd 100644 --- a/common/src/java/org/apache/hadoop/hive/common/FileUtils.java +++ b/common/src/java/org/apache/hadoop/hive/common/FileUtils.java @@ -999,31 +999,29 @@ public final class FileUtils { * @return the list of the file names in the format of URI formats. */ public static Set<String> getJarFilesByPath(String pathString, Configuration conf) { - Set<String> result = new HashSet<String>(); - if (pathString == null || org.apache.commons.lang.StringUtils.isBlank(pathString)) { - return result; + if (org.apache.commons.lang.StringUtils.isBlank(pathString)) { + return Collections.emptySet(); } - + Set<String> result = new HashSet<>(); String[] paths = pathString.split(","); - for(String path : paths) { + for (final String path : paths) { try { Path p = new Path(getURI(path)); FileSystem fs = p.getFileSystem(conf); - if (!fs.exists(p)) { - LOG.error("The jar file path " + path + " doesn't exist"); - continue; - } - if (fs.isDirectory(p)) { + FileStatus fileStatus = fs.getFileStatus(p); + if (fileStatus.isDirectory()) { // add all jar files under the folder FileStatus[] files = fs.listStatus(p, new GlobFilter("*.jar")); - for(FileStatus file : files) { + for (FileStatus file : files) { result.add(file.getPath().toUri().toString()); } } else { result.add(p.toUri().toString()); } - } catch(URISyntaxException | IOException e) { - LOG.error("Invalid file path " + path, e); + } catch (FileNotFoundException fnfe) { + LOG.error("The jar file path {} does not exist", path); + } catch (URISyntaxException | IOException e) { + LOG.error("Invalid file path {}", path, e); } } return result;
