Details
-
Bug
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
0.20.2, 3.3.3, 3.3.4, 3.3.6
-
Reviewed
Description
When use fs shell to put/rename file in ftp server with full qualified path , it always get "Input/output error"(eg. ftp://user:password@localhost/pathxxx), the reason is that changeWorkingDirectory command underneath is being passed a string with file:// uri prefix which will not be understand by ftp server
in our case, after client.changeWorkingDirectory("ftp://mytest:mytest@10.5.xx.xx/files")
executed, the workingDirectory of ftp server is still "/", which is incorrect(not understand by ftp server)
the solution should be pass absoluteSrc.getParent().toUri().getPath().toString to avoid
file:// uri prefix, like this:
--- a/FTPFileSystem.java +++ b/FTPFileSystem.java @@ -549,15 +549,15 @@ public class FTPFileSystem extends FileSystem { throw new IOException("Destination path " + dst + " already exist, cannot rename!"); } - String parentSrc = absoluteSrc.getParent().toUri().toString(); - String parentDst = absoluteDst.getParent().toUri().toString(); + URI parentSrc = absoluteSrc.getParent().toUri(); + URI parentDst = absoluteDst.getParent().toUri(); String from = src.getName(); String to = dst.getName(); - if (!parentSrc.equals(parentDst)) { + if (!parentSrc.toString().equals(parentDst.toString())) { throw new IOException("Cannot rename parent(source): " + parentSrc + ", parent(destination): " + parentDst); } - client.changeWorkingDirectory(parentSrc); + client.changeWorkingDirectory(parentSrc.getPath().toString()); boolean renamed = client.rename(from, to); return renamed; }
already related issue as follows
https://issues.apache.org/jira/browse/HADOOP-8653
I create this issue and add related unit test.
Attachments
Attachments
Issue Links
- links to