You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by bo...@apache.org on 2018/07/27 04:36:04 UTC
hadoop git commit: HADOOP-15629. Missing trimming in readlink in case
of protocol. Contrbuted by Giovanni Matteo Fumarola
Repository: hadoop
Updated Branches:
refs/heads/HADOOP-15461 bac459b3f -> d71df5aac
HADOOP-15629. Missing trimming in readlink in case of protocol. Contrbuted by Giovanni Matteo Fumarola
Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/d71df5aa
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/d71df5aa
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/d71df5aa
Branch: refs/heads/HADOOP-15461
Commit: d71df5aac9c7df9303cef7a5ba740bfe20958374
Parents: bac459b
Author: Botong Huang <bo...@apache.org>
Authored: Thu Jul 26 21:35:13 2018 -0700
Committer: Botong Huang <bo...@apache.org>
Committed: Thu Jul 26 21:35:13 2018 -0700
----------------------------------------------------------------------
.../java/org/apache/hadoop/fs/FileUtil.java | 21 +++++++++++++++-----
1 file changed, 16 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hadoop/blob/d71df5aa/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileUtil.java
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileUtil.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileUtil.java
index bf3feb5..ab3d913 100644
--- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileUtil.java
+++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileUtil.java
@@ -30,7 +30,10 @@ import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.InetAddress;
+import java.net.MalformedURLException;
import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
import java.net.UnknownHostException;
import java.nio.charset.Charset;
import java.nio.file.AccessDeniedException;
@@ -203,18 +206,26 @@ public class FileUtil {
return "";
}
- if (Files.isSymbolicLink(f.toPath())) {
+ // This will make sure we remove the protocol as file://
+ java.nio.file.Path pathFile;
+ try {
+ pathFile = Paths.get(new URL(f.toString()).toURI());
+ } catch (MalformedURLException | URISyntaxException e) {
+ pathFile = f.toPath();
+ }
+
+ if (Files.isSymbolicLink(pathFile)) {
java.nio.file.Path p = null;
try {
- p = Files.readSymbolicLink(f.toPath());
+ p = Files.readSymbolicLink(pathFile);
} catch (Exception e) {
- LOG.warn("Exception while reading the symbolic link "
- + f.getAbsolutePath() + ". Exception= " + e.getMessage());
+ LOG.warn("Exception while reading the symbolic link {}. Exception= {}",
+ f, e.getMessage());
return "";
}
return p.toAbsolutePath().toString();
}
- LOG.warn("The file " + f.getAbsolutePath() + " is not a symbolic link.");
+ LOG.warn("The file {} is not a symbolic link.", f);
return "";
}
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org